diff options
author | Evan Huus <eapache@gmail.com> | 2012-12-27 22:31:42 +0000 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2012-12-27 22:31:42 +0000 |
commit | dc98756ca4b6c0966c90ca8925653b7b1759941b (patch) | |
tree | 11f27ccb360eb2abf2aa5b0e8aa352ab88b2f3c6 | |
parent | 347a8a2115c8de01a0bc80f2e7744e00f3034cc2 (diff) |
Store the type of each wmem allocator.
svn path=/trunk/; revision=46814
-rw-r--r-- | epan/wmem/wmem_allocator.h | 5 | ||||
-rw-r--r-- | epan/wmem/wmem_core.c | 16 |
2 files changed, 17 insertions, 4 deletions
diff --git a/epan/wmem/wmem_allocator.h b/epan/wmem/wmem_allocator.h index e3246e7ed6..c9ce8ab49f 100644 --- a/epan/wmem/wmem_allocator.h +++ b/epan/wmem/wmem_allocator.h @@ -32,12 +32,15 @@ extern "C" { #endif /* __cplusplus */ +typedef enum _wmem_allocator_type_t wmem_allocator_type_t; + struct _wmem_allocator_t { void *(*alloc)(void *private_data, const size_t size); void (*free_all)(void *private_data); void (*destroy)(struct _wmem_allocator_t *allocator); - void *private_data; + void *private_data; + wmem_allocator_type_t type; }; #ifdef __cplusplus diff --git a/epan/wmem/wmem_core.c b/epan/wmem/wmem_core.c index c3006b0125..8181ace30a 100644 --- a/epan/wmem/wmem_core.c +++ b/epan/wmem/wmem_core.c @@ -65,19 +65,25 @@ wmem_destroy_allocator(wmem_allocator_t *allocator) wmem_allocator_t * wmem_allocator_new(const wmem_allocator_type_t type) { + wmem_allocator_t *allocator; + /* 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")) { - return wmem_simple_allocator_new(); + allocator = wmem_simple_allocator_new(); + allocator->type = WMEM_ALLOCATOR_SIMPLE; + return allocator; } switch (type) { case WMEM_ALLOCATOR_SIMPLE: - return wmem_simple_allocator_new(); + allocator = wmem_simple_allocator_new(); + break; case WMEM_ALLOCATOR_BLOCK: - return wmem_block_allocator_new(); + allocator = wmem_block_allocator_new(); + break; default: g_assert_not_reached(); /* This is necessary to squelch MSVC errors; is there @@ -85,6 +91,10 @@ wmem_allocator_new(const wmem_allocator_type_t type) never returns? */ return NULL; }; + + allocator->type = type; + + return allocator; } void |