From 6ea1f3c5f2809d5ad2e03e8cb06f672e6d4ee4c2 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Sun, 30 Jun 2024 17:56:48 +0200 Subject: [PATCH] tests: list: release resources on exit Signed-off-by: Eduardo Silva --- tests/list.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/list.c b/tests/list.c index 28b751f..9717be4 100644 --- a/tests/list.c +++ b/tests/list.c @@ -45,8 +45,11 @@ static void checks() static void add() { int i; + int count = 0; struct cfl_list list; struct cfl_list *head; + struct cfl_list *tmp; + struct node { int value; struct cfl_list _head; @@ -74,7 +77,18 @@ static void add() cfl_list_foreach(head, &list) { node = cfl_list_entry(head, struct node, _head); printf("node value: %d\n", node->value); + count++; } + TEST_CHECK(count == 3); + + cfl_list_foreach_safe(head, tmp, &list) { + node = cfl_list_entry(head, struct node, _head); + cfl_list_del(&node->_head); + free(node); + count++; + } + + free(nodes); } TEST_LIST = {