From 3c058f07a98fe1bc35390099e9674509a74a8d3f Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Fri, 8 Oct 2021 23:59:35 -0700 Subject: [PATCH] Add an option to disable automatic use of `getenv` inside options.c --- src/options.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/options.c b/src/options.c index 30025db2..2dc7bfee 100644 --- a/src/options.c +++ b/src/options.c @@ -409,6 +409,14 @@ static void mi_strlcat(char* dest, const char* src, size_t dest_size) { 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) { if (n==0) return 0; 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); } - #if defined _WIN32 // On Windows use GetEnvironmentVariable instead of getenv to work // 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 static void mi_option_init(mi_option_desc_t* desc) { // Read option value from the environment