fix: test leak

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

View File

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