mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-05 15:09:31 +03:00
Merge pull request #465 from thomcc/no-getenv
Add an option to disable environment access inside options.c
This commit is contained in:
commit
4841bc1721
1 changed files with 9 additions and 1 deletions
|
@ -409,6 +409,14 @@ static void mi_strlcat(char* dest, const char* src, size_t dest_size) {
|
||||||
dest[dest_size - 1] = 0;
|
dest[dest_size - 1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MI_NO_GETENV
|
||||||
|
static bool mi_getenv(const char* name, char* result, size_t result_size) {
|
||||||
|
UNUSED(name);
|
||||||
|
UNUSED(result);
|
||||||
|
UNUSED(result_size);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
static inline int mi_strnicmp(const char* s, const char* t, size_t n) {
|
static inline int mi_strnicmp(const char* s, const char* t, size_t n) {
|
||||||
if (n==0) return 0;
|
if (n==0) return 0;
|
||||||
for (; *s != 0 && *t != 0 && n > 0; s++, t++, n--) {
|
for (; *s != 0 && *t != 0 && n > 0; s++, t++, n--) {
|
||||||
|
@ -416,7 +424,6 @@ static inline int mi_strnicmp(const char* s, const char* t, size_t n) {
|
||||||
}
|
}
|
||||||
return (n==0 ? 0 : *s - *t);
|
return (n==0 ? 0 : *s - *t);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined _WIN32
|
#if defined _WIN32
|
||||||
// On Windows use GetEnvironmentVariable instead of getenv to work
|
// On Windows use GetEnvironmentVariable instead of getenv to work
|
||||||
// reliably even when this is invoked before the C runtime is initialized.
|
// reliably even when this is invoked before the C runtime is initialized.
|
||||||
|
@ -485,6 +492,7 @@ static bool mi_getenv(const char* name, char* result, size_t result_size) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
static void mi_option_init(mi_option_desc_t* desc) {
|
static void mi_option_init(mi_option_desc_t* desc) {
|
||||||
// Read option value from the environment
|
// Read option value from the environment
|
||||||
|
|
Loading…
Add table
Reference in a new issue