diff options
author | Evan Huus <eapache@gmail.com> | 2013-02-14 16:23:22 +0000 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2013-02-14 16:23:22 +0000 |
commit | cb679f279b67701103652b8cbf1d09e648d185cb (patch) | |
tree | 1096cbaadd4c0394e3873ba4b7aed841341f05a5 /epan/wmem/wmem_core.c | |
parent | 5071e8b6277238631c2123e1c56f31c0658bc61d (diff) |
If the requested wmem allocator is NULL, take that to mean manually-managed
memory. This permits using manually-scoped versions of certain wmem structures.
svn path=/trunk/; revision=47657
Diffstat (limited to 'epan/wmem/wmem_core.c')
-rw-r--r-- | epan/wmem/wmem_core.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/epan/wmem/wmem_core.c b/epan/wmem/wmem_core.c index e15f1ff913..87a218bdbc 100644 --- a/epan/wmem/wmem_core.c +++ b/epan/wmem/wmem_core.c @@ -37,6 +37,10 @@ void * wmem_alloc(wmem_allocator_t *allocator, const size_t size) { + if (allocator == NULL) { + return g_malloc(size); + } + if (size == 0) { return NULL; } @@ -61,6 +65,11 @@ wmem_alloc0(wmem_allocator_t *allocator, const size_t size) void wmem_free(wmem_allocator_t *allocator, void *ptr) { + if (allocator == NULL) { + g_free(ptr); + return; + } + if (ptr == NULL) { return; } @@ -71,6 +80,10 @@ wmem_free(wmem_allocator_t *allocator, void *ptr) void * wmem_realloc(wmem_allocator_t *allocator, void *ptr, const size_t size) { + if (allocator == NULL) { + return g_realloc(ptr, size); + } + if (ptr == NULL) { return wmem_alloc(allocator, size); } |