add preload check in option initialization (issues #179)

This commit is contained in:
Daan Leijen 2019-12-01 01:03:39 -08:00
parent acb03c5497
commit e31e609414

View file

@ -366,6 +366,10 @@ static bool mi_getenv(const char* name, char* result, size_t result_size) {
} }
#endif #endif
static void mi_option_init(mi_option_desc_t* desc) { static void mi_option_init(mi_option_desc_t* desc) {
#ifndef _WIN32
// cannot call getenv() when still initializing the C runtime.
if (_mi_preloading()) return;
#endif
// Read option value from the environment // Read option value from the environment
char buf[64+1]; char buf[64+1];
mi_strlcpy(buf, "mimalloc_", sizeof(buf)); mi_strlcpy(buf, "mimalloc_", sizeof(buf));