fix: test leak
This commit is contained in:
parent
3effb7caf5
commit
ebf0b0e442
2
Makefile
2
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)
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user