diff options
author | Evan Huus <eapache@gmail.com> | 2012-12-27 22:51:33 +0000 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2012-12-27 22:51:33 +0000 |
commit | 442b61d0a41b18951366a17e8f612d1ccbb00a1a (patch) | |
tree | 42a3c617dd73960e84b6d4c73a69546a6eb8cacf | |
parent | f88d8e48c165ebd1ec95834c2a2b5815103566c3 (diff) |
Change the format of the environment variable slightly to allow overriding
allocator choice to use any specific allocator, not just simple.
svn path=/trunk/; revision=46816
-rw-r--r-- | epan/wmem/wmem_core.c | 26 | ||||
-rwxr-xr-x | tools/valgrind-wireshark.sh | 2 |
2 files changed, 20 insertions, 8 deletions
diff --git a/epan/wmem/wmem_core.c b/epan/wmem/wmem_core.c index 8181ace30a..5a05332c56 100644 --- a/epan/wmem/wmem_core.c +++ b/epan/wmem/wmem_core.c @@ -65,19 +65,31 @@ wmem_destroy_allocator(wmem_allocator_t *allocator) wmem_allocator_t * wmem_allocator_new(const wmem_allocator_type_t type) { - wmem_allocator_t *allocator; + const char *override; + wmem_allocator_t *allocator; + wmem_allocator_type_t real_type; /* Our valgrind script uses this environment variable to override the * usual allocator choice so that everything goes through system-level * allocations that it understands and can track. Otherwise it will get * confused by the block allocator etc. */ - if (getenv("WIRESHARK_DEBUG_WMEM_SIMPLE")) { - allocator = wmem_simple_allocator_new(); - allocator->type = WMEM_ALLOCATOR_SIMPLE; - return allocator; + override = getenv("WIRESHARK_DEBUG_WMEM_OVERRIDE"); + + if (override == NULL) { + real_type = type; + } + else if (strncmp(override, "simple", strlen("simple")) == 0) { + real_type = WMEM_ALLOCATOR_SIMPLE; + } + else if (strncmp(override, "block", strlen("block")) == 0) { + real_type = WMEM_ALLOCATOR_BLOCK; + } + else { + g_warning("Unrecognized wmem override"); + real_type = type; } - switch (type) { + switch (real_type) { case WMEM_ALLOCATOR_SIMPLE: allocator = wmem_simple_allocator_new(); break; @@ -92,7 +104,7 @@ wmem_allocator_new(const wmem_allocator_type_t type) return NULL; }; - allocator->type = type; + allocator->type = real_type; return allocator; } diff --git a/tools/valgrind-wireshark.sh b/tools/valgrind-wireshark.sh index b6c5903bdd..c941ed39f6 100755 --- a/tools/valgrind-wireshark.sh +++ b/tools/valgrind-wireshark.sh @@ -78,7 +78,7 @@ fi export WIRESHARK_DEBUG_EP_NO_CHUNKS= export WIRESHARK_DEBUG_SE_NO_CHUNKS= -export WIRESHARK_DEBUG_WMEM_SIMPLE= +export WIRESHARK_DEBUG_WMEM_OVERRIDE=simple export G_SLICE=always-malloc # or debug-blocks libtool --mode=execute valgrind $LEAK_CHECK $REACHABLE $TRACK_ORIGINS $BIN_DIR/$COMMAND $COMMAND_ARGS $PCAP $COMMAND_ARGS2 > /dev/null |