Free all the data structures associated with test cases.
Removes some of the memory leaks discovered by AddressSanitizer
in the test suite (see Issue
@@ -70,6 +70,24 @@ tcase_add_test(TCase *tc, tcase_test_function test)
tc->ntests++;
}
+static void
+tcase_dispose(TCase *tc)
+{
+ free(tc->tests);
+ free(tc);
+}
+
+static void
+suite_dispose(Suite *suite)
+{
+ while (suite->tests != NULL) {
+ TCase *next = suite->tests->next_tcase;
+ tcase_dispose(suite->tests);
+ suite->tests = next;
+ }
+ free(suite);
+}
+
SRunner *
srunner_create(Suite *suite)
{
@@ -175,6 +193,6 @@ srunner_ntests_failed(SRunner *runner)
void
srunner_free(SRunner *runner)
{
- free(runner->suite);
+ suite_dispose(runner->suite);
free(runner);
}
