From ebf0b0e44241dfa5075d3c9bc57d10c909dba418 Mon Sep 17 00:00:00 2001 From: starnakin Date: Wed, 11 Sep 2024 20:20:49 +0200 Subject: [PATCH] fix: test leak --- Makefile | 2 +- test/test.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b12f0f0..1a29046 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ all : $(NAME) test : $(NAME) $(CC) $(CFLAGS) test/test.c $(BUILDDIR)/$(NAME) -o $(BUILDDIR)/test - $(BUILDDIR)/test + valgrind --leak-check=full $(BUILDDIR)/test clean : rm -rf $(OBJDIR) diff --git a/test/test.c b/test/test.c index 4756735..57365c1 100644 --- a/test/test.c +++ b/test/test.c @@ -84,7 +84,8 @@ void destroy_list(t_list *root, void *(destroy_data)(void *)) { prev = current; if (current->data) - destroy_data(current->data); + if (destroy_data) + destroy_data(current->data); current = current->next; free(prev); } @@ -134,6 +135,7 @@ void multiple_test_list_size() if (root == NULL) return; test_int(len, ft_list_size(root)); + destroy_list(root, NULL); printf("\n"); } } @@ -160,6 +162,7 @@ void multiple_test_push_front() printf(" list-size: "); test_int(len + 1, ft_list_size(root)); printf("\n"); + destroy_list(root, NULL); } }