fix: test leak

This commit is contained in:
starnakin 2024-09-11 20:20:49 +02:00
parent 3effb7caf5
commit ebf0b0e442
2 changed files with 5 additions and 2 deletions

View File

@ -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)

View File

@ -84,6 +84,7 @@ void destroy_list(t_list *root, void *(destroy_data)(void *))
{
prev = current;
if (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);
}
}