summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2017-12-03 10:14:33 +0300
committerIvan Maidanski <ivmai@mail.ru>2017-12-11 11:03:37 +0300
commita02c06b80712cff70eb668e4872b40794275deaf (patch)
tree30a10352f769e3a2908c4bd0229a197b92badd36
parent3978e9d7010d724bbd88b51e27cb5ee5315a694a (diff)
downloadlibatomic_ops-a02c06b80712cff70eb668e4872b40794275deaf.tar.gz
Fix memory leak in test_malloc
* tests/test_malloc.c (free_list): New function definition. * tests/test_malloc.c (run_one_test): Call free_list(x) on return.
-rw-r--r--tests/test_malloc.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/test_malloc.c b/tests/test_malloc.c
index dca06da..1695a81 100644
--- a/tests/test_malloc.c
+++ b/tests/test_malloc.c
@@ -140,6 +140,15 @@ make_list(int m, int n)
return cons(m, make_list(m+1, n));
}
+void free_list(ln *x)
+{
+ while (x != NULL) {
+ ln *next = x -> next;
+ AO_free(x);
+ x = next;
+ }
+}
+
/* Reverse list x, and concatenate it to y, deallocating no longer needed */
/* nodes in x. */
ln *
@@ -202,6 +211,7 @@ void * run_one_test(void * arg) {
x = reverse(x, 0);
}
check_list(x, 1, LIST_LENGTH);
+ free_list(x);
return arg; /* use arg to suppress compiler warning */
}