mirror of
https://github.com/microsoft/mimalloc.git
synced 2024-12-28 22:05:40 +08:00
avoid using atexit in a Windows dll; potential fix for #512
This commit is contained in:
parent
2cc400d600
commit
7a4104b3a9
13
src/init.c
13
src/init.c
@ -446,7 +446,9 @@ static void mi_process_load(void) {
|
|||||||
MI_UNUSED(dummy);
|
MI_UNUSED(dummy);
|
||||||
#endif
|
#endif
|
||||||
os_preloading = false;
|
os_preloading = false;
|
||||||
atexit(&mi_process_done);
|
#if !(defined(_WIN32) && defined(MI_SHARED_LIB)) // use Dll process detach (see below) instead of atexit (issue #521)
|
||||||
|
atexit(&mi_process_done);
|
||||||
|
#endif
|
||||||
_mi_options_init();
|
_mi_options_init();
|
||||||
mi_process_init();
|
mi_process_init();
|
||||||
//mi_stats_reset();-
|
//mi_stats_reset();-
|
||||||
@ -558,9 +560,14 @@ static void mi_process_done(void) {
|
|||||||
if (reason==DLL_PROCESS_ATTACH) {
|
if (reason==DLL_PROCESS_ATTACH) {
|
||||||
mi_process_load();
|
mi_process_load();
|
||||||
}
|
}
|
||||||
else if (reason==DLL_THREAD_DETACH) {
|
else if (reason==DLL_PROCESS_DETACH) {
|
||||||
if (!mi_is_redirected()) mi_thread_done();
|
mi_process_done();
|
||||||
}
|
}
|
||||||
|
else if (reason==DLL_THREAD_DETACH) {
|
||||||
|
if (!mi_is_redirected()) {
|
||||||
|
mi_thread_done();
|
||||||
|
}
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user