diff --git a/epan/wmem/wmem_list.c b/epan/wmem/wmem_list.c index df9f07ceee..592d51b432 100644 --- a/epan/wmem/wmem_list.c +++ b/epan/wmem/wmem_list.c @@ -173,6 +173,22 @@ wmem_list_new(wmem_allocator_t *allocator) return list; } +void +wmem_destroy_list(wmem_list_t *list) +{ + wmem_list_frame_t *cur, *next; + + cur = list->head; + + while (cur) { + next = cur->next; + wmem_free(list->allocator, cur); + cur = next; + } + + wmem_free(list->allocator, list); +} + /* * Editor modelines - http://www.wireshark.org/tools/modelines.html * diff --git a/epan/wmem/wmem_list.h b/epan/wmem/wmem_list.h index 65bd0073db..a753070a47 100644 --- a/epan/wmem/wmem_list.h +++ b/epan/wmem/wmem_list.h @@ -95,6 +95,10 @@ wmem_list_t * wmem_list_new(wmem_allocator_t *allocator) G_GNUC_MALLOC; +WS_DLL_PUBLIC +void +wmem_destroy_list(wmem_list_t *list); + /** @} * @} */ diff --git a/epan/wmem/wmem_queue.h b/epan/wmem/wmem_queue.h index c79489402c..90090c01d2 100644 --- a/epan/wmem/wmem_queue.h +++ b/epan/wmem/wmem_queue.h @@ -58,6 +58,8 @@ typedef wmem_list_t wmem_queue_t; #define wmem_queue_new(ALLOCATOR) wmem_list_new(ALLOCATOR) +#define wmem_destroy_queue(QUEUE) wmem_destroy_list(QUEUE) + /** @} * @} */ diff --git a/epan/wmem/wmem_stack.h b/epan/wmem/wmem_stack.h index e2435c9b96..7cc667126b 100644 --- a/epan/wmem/wmem_stack.h +++ b/epan/wmem/wmem_stack.h @@ -62,6 +62,8 @@ wmem_stack_pop(wmem_stack_t *stack); #define wmem_stack_new(ALLOCATOR) wmem_list_new(ALLOCATOR) +#define wmem_destroy_stack(STACK) wmem_destroy_list(STACK) + /** @} * @} */ diff --git a/epan/wmem/wmem_test.c b/epan/wmem/wmem_test.c index 00139ef4a7..6e83e4b322 100644 --- a/epan/wmem/wmem_test.c +++ b/epan/wmem/wmem_test.c @@ -593,6 +593,13 @@ wmem_test_list(void) } wmem_destroy_allocator(allocator); + + list = wmem_list_new(NULL); + for (i=0; i