diff options
author | Aliaksey Kandratsenka <alk@tut.by> | 2014-04-12 18:06:32 -0700 |
---|---|---|
committer | Aliaksey Kandratsenka <alk@tut.by> | 2014-04-12 18:06:32 -0700 |
commit | 6b83516adefcf0806825f6dba2eb2232615d744b (patch) | |
tree | 5eee46db8ee1103132d2adf05300222051b36271 | |
parent | aeef3b44201ba663c19ca1c97792b724346e84a9 (diff) | |
download | gperftools-6b83516adefcf0806825f6dba2eb2232615d744b.tar.gz |
issue-610: made dynamic_annotations.c use TCMallocGetenvSafe
-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 */ |