aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wmem
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2016-01-02 07:38:43 +0000
committerJoão Valverde <j@v6e.pt>2020-07-22 22:46:28 +0000
commit7be4a8fb0057839062b5dd061fd871f3f0943acc (patch)
tree89eb02e9d06a178b2aa3ec8960296aa43d3ff81a /epan/wmem
parentc8bda0764112a454709859b388e6a4d2129b8ef1 (diff)
Add wmem_destroy_array()
Change-Id: I00a0052a9c207692eddab7ac2d0f146201648f6c Reviewed-on: https://code.wireshark.org/review/13003 Reviewed-by: João Valverde <j@v6e.pt>
Diffstat (limited to 'epan/wmem')
-rw-r--r--epan/wmem/wmem_array.c7
-rw-r--r--epan/wmem/wmem_array.h4
-rw-r--r--epan/wmem/wmem_test.c4
3 files changed, 15 insertions, 0 deletions
diff --git a/epan/wmem/wmem_array.c b/epan/wmem/wmem_array.c
index bf106764d2..27a836f33e 100644
--- a/epan/wmem/wmem_array.c
+++ b/epan/wmem/wmem_array.c
@@ -158,6 +158,13 @@ wmem_array_get_count(wmem_array_t *array)
return array->elem_count;
}
+void
+wmem_destroy_array(wmem_array_t *array)
+{
+ wmem_free(array->allocator, array->buf);
+ wmem_free(array->allocator, array);
+}
+
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
diff --git a/epan/wmem/wmem_array.h b/epan/wmem/wmem_array.h
index 0fdd27fce9..c1fd708410 100644
--- a/epan/wmem/wmem_array.h
+++ b/epan/wmem/wmem_array.h
@@ -80,6 +80,10 @@ WS_DLL_PUBLIC
guint
wmem_array_get_count(wmem_array_t *array);
+WS_DLL_PUBLIC
+void
+wmem_destroy_array(wmem_array_t *array);
+
/** @}
* @} */
diff --git a/epan/wmem/wmem_test.c b/epan/wmem/wmem_test.c
index 8082fe8324..c25e095829 100644
--- a/epan/wmem/wmem_test.c
+++ b/epan/wmem/wmem_test.c
@@ -671,6 +671,8 @@ wmem_test_array(void)
g_assert(val == i);
}
+ wmem_destroy_array(array);
+
array = wmem_array_sized_new(allocator, sizeof(guint32), 73);
wmem_array_set_null_terminator(array);
for (i=0; i<75; i++)
@@ -725,6 +727,8 @@ wmem_test_array(void)
g_assert(raw[wmem_array_get_count(array)] == 0);
g_assert(raw[wmem_array_get_count(array) - 1] == lastint);
+ wmem_destroy_array(array);
+
wmem_destroy_allocator(allocator);
}