aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wmem/wmem_core.c
diff options
context:
space:
mode:
authorEvan Huus <eapache@gmail.com>2013-05-22 15:42:12 +0000
committerEvan Huus <eapache@gmail.com>2013-05-22 15:42:12 +0000
commit5426ba4e027326d7b5bea08fd1bb8cfab0847c76 (patch)
tree16147df109ecbdf895d72ea44cf10462f2e38933 /epan/wmem/wmem_core.c
parenta2f6822feab6985a3b097dec62de3691ae6d57d6 (diff)
Minor refactor: make the framework responsible for allocating and freeing the
actual wmem_allocator_t structure. This simplifies the internal API and deduplicates a few alloc/free calls in the individual allocator implementations. I'd originally made the allocators responsible for this on purpose with the idea that they'd be able to optimize something clever based on the type of allocator, but that's clearly more work and complexity than it's worth given the small number of allocators we create/destroy. svn path=/trunk/; revision=49512
Diffstat (limited to 'epan/wmem/wmem_core.c')
-rw-r--r--epan/wmem/wmem_core.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/epan/wmem/wmem_core.c b/epan/wmem/wmem_core.c
index f8b24557e4..7ffe0fedad 100644
--- a/epan/wmem/wmem_core.c
+++ b/epan/wmem/wmem_core.c
@@ -123,7 +123,8 @@ wmem_destroy_allocator(wmem_allocator_t *allocator)
{
wmem_free_all_real(allocator, TRUE);
- allocator->destroy(allocator);
+ allocator->cleanup(allocator->private_data);
+ g_slice_free(wmem_allocator_t, allocator);
}
wmem_allocator_t *
@@ -156,15 +157,19 @@ wmem_allocator_new(const wmem_allocator_type_t type)
real_type = type;
}
+ allocator = g_slice_new(wmem_allocator_t);
+ allocator->type = real_type;
+ allocator->callbacks = NULL;
+
switch (real_type) {
case WMEM_ALLOCATOR_SIMPLE:
- allocator = wmem_simple_allocator_new();
+ wmem_simple_allocator_init(allocator);
break;
case WMEM_ALLOCATOR_BLOCK:
- allocator = wmem_block_allocator_new();
+ wmem_block_allocator_init(allocator);
break;
case WMEM_ALLOCATOR_STRICT:
- allocator = wmem_strict_allocator_new();
+ wmem_strict_allocator_init(allocator);
break;
default:
g_assert_not_reached();
@@ -174,9 +179,6 @@ wmem_allocator_new(const wmem_allocator_type_t type)
return NULL;
};
- allocator->type = real_type;
- allocator->callbacks = NULL;
-
return allocator;
}