Skip to content

Commit

Permalink
tests: list: release resources on exit
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Silva <[email protected]>
  • Loading branch information
edsiper committed Jun 30, 2024
1 parent c170980 commit 6ea1f3c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit 6ea1f3c

Please sign in to comment.