diff options
-rw-r--r-- | src/base/dynamic_annotations.c | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/src/base/dynamic_annotations.c b/src/base/dynamic_annotations.c index c8b61be..87bd2ec 100644 --- a/src/base/dynamic_annotations.c +++ b/src/base/dynamic_annotations.c @@ -40,6 +40,7 @@ #include <string.h> #include "base/dynamic_annotations.h" +#include "getenv_safe.h" // for TCMallocGetenvSafe #ifdef __GNUC__ /* valgrind.h uses gcc extensions so it won't build with other compilers */ @@ -140,23 +141,11 @@ static int GetRunningOnValgrind(void) { #ifdef RUNNING_ON_VALGRIND if (RUNNING_ON_VALGRIND) return 1; #endif -#ifdef _MSC_VER - /* Visual Studio can complain about getenv, so use a windows equivalent. */ - char value[100] = "1"; /* something that is not "0" */ - int res = GetEnvironmentVariableA("RUNNING_ON_VALGRIND", - value, sizeof(value)); - /* value will remain "1" if the called failed for some reason. */ - return (res > 0 && strcmp(value, "0") != 0); -#else - /* TODO(csilvers): use GetenvBeforeMain() instead? Will need to - * change it to be extern "C". - */ - char *running_on_valgrind_str = getenv("RUNNING_ON_VALGRIND"); + const char *running_on_valgrind_str = TCMallocGetenvSafe("RUNNING_ON_VALGRIND"); if (running_on_valgrind_str) { return strcmp(running_on_valgrind_str, "0") != 0; } return 0; -#endif } /* See the comments in dynamic_annotations.h */ |