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
This commit is contained in:
Evan Huus 2012-12-27 22:51:33 +00:00
parent f88d8e48c1
commit 442b61d0a4
2 changed files with 20 additions and 8 deletions

View File

@ -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;
}

View File

@ -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