On Thu, 6 Apr 2023, Martin Storsjö wrote:
On Thu, 6 Apr 2023, LIU Hao wrote:
在 2023/4/6 16:28, Martin Storsjö 写道:
diff --git a/mingw-w64-crt/crt/tls_atexit.c
b/mingw-w64-crt/crt/tls_atexit.c
index f39731ad7..284fd675d 100644
--- a/mingw-w64-crt/crt/tls_atexit.c
+++ b/mingw-w64-crt/crt/tls_atexit.
@@ -54,12 +54,13 @@ int __mingw_cxa_atexit(dtor_fn dtor, void *obj,
void *dso) {
}
static void run_dtor_list(dtor_obj **ptr) {
- dtor_obj *list = *ptr;
- while (list) {
- list->dtor(list->obj);
- dtor_obj *next = list->next;
- free(list);
- list = next;
+ if (!ptr)
+ return;
+ while (*ptr) {
+ dtor_obj *cur = *ptr;
+ *ptr = cur->next;
+ cur->dtor(cur->obj);
+ free(cur);
}
*ptr = NULL;
^^^^^^^^^^^
This assignment is now redundant and should be deleted.
Good catch, thanks - will update it locally that way.
The other parts look good to me.
I don't like the idea about allocating storage for something just a
pointer, but given how `run_dtor_list()` is implemented, that makes
some sense on its own.
Yeah, me neither. I guess the alternative would be to make a tls specific
version of run_dtor_list, which uses TlsSetValue/TlsGetValue for each
iteration to update the list head that way - and compared with that, I
find this version slightly neater still.
I'll push this sometime later then, with the cleanup you pointed out.
Pushed now.
// Martin
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public