mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-07 03:48:42 +03:00
merge from dev
This commit is contained in:
commit
b0ba746307
4 changed files with 28 additions and 7 deletions
15
src/init.c
15
src/init.c
|
@ -409,15 +409,24 @@ void mi_thread_done(void) mi_attr_noexcept {
|
|||
_mi_thread_done(NULL);
|
||||
}
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void _mi_thread_done(mi_heap_t* heap)
|
||||
{
|
||||
mi_atomic_decrement_relaxed(&thread_count);
|
||||
_mi_stat_decrease(&_mi_stats_main.threads, 1);
|
||||
|
||||
// calling with NULL implies using the default heap
|
||||
if (heap == NULL) {
|
||||
heap = mi_prim_get_default_heap();
|
||||
if (heap == NULL) return;
|
||||
}
|
||||
|
||||
// prevent re-entrancy through heap_done/heap_set_default_direct (issue #699)
|
||||
if (!mi_heap_is_initialized(heap)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// adjust stats
|
||||
mi_atomic_decrement_relaxed(&thread_count);
|
||||
_mi_stat_decrease(&_mi_stats_main.threads, 1);
|
||||
|
||||
// check thread-id as on Windows shutdown with FLS the main (exit) thread may call this on thread-local heaps...
|
||||
if (heap->thread_id != _mi_thread_id()) return;
|
||||
|
|
|
@ -629,8 +629,8 @@ bool _mi_prim_getenv(const char* name, char* result, size_t result_size) {
|
|||
if (len == 0) return false;
|
||||
char** env = mi_get_environ();
|
||||
if (env == NULL) return false;
|
||||
// compare up to 256 entries
|
||||
for (int i = 0; i < 256 && env[i] != NULL; i++) {
|
||||
// compare up to 64K entries
|
||||
for (int i = 0; i < 64*MI_KiB && env[i] != NULL; i++) {
|
||||
const char* s = env[i];
|
||||
if (_mi_strnicmp(name, s, len) == 0 && s[len] == '=') { // case insensitive
|
||||
// found it
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue