[glib: 3/9] glib/gtestutils: Introduce and use a g_test_suite_free function




commit 353f0b523537a4cf993a9835cbd58051d5e6b043
Author: GOUJON Évan <goujon evan gmail com>
Date:   Fri Jul 23 22:16:44 2021 +0200

    glib/gtestutils: Introduce and use a g_test_suite_free function

 docs/reference/glib/glib-sections.txt |  1 +
 glib/gtestutils.c                     | 21 +++++++++++++++++++++
 glib/gtestutils.h                     |  3 +++
 3 files changed, 25 insertions(+)
---
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index b087fe050..409f8e1be 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -3639,6 +3639,7 @@ g_test_suite_add
 g_test_suite_add_suite
 g_test_run_suite
 g_test_case_free
+g_test_suite_free
 
 <SUBSECTION Private>
 g_test_trap_assertions
diff --git a/glib/gtestutils.c b/glib/gtestutils.c
index ce53a8047..ab80e48b2 100644
--- a/glib/gtestutils.c
+++ b/glib/gtestutils.c
@@ -2216,6 +2216,7 @@ g_test_run (void)
     }
 
 out:
+  g_test_suite_free (suite);
   return ret;
 }
 
@@ -3009,6 +3010,26 @@ g_test_case_free (GTestCase *test_case)
   g_slice_free (GTestCase, test_case);
 }
 
+/**
+ * g_test_suite_free:
+ * @suite: a #GTestSuite
+ *
+ * Free the @suite and all nested #GTestSuites.
+ *
+ * Since: 2.70
+ */
+void
+g_test_suite_free (GTestSuite *suite)
+{
+  g_slist_free_full (suite->cases, (GDestroyNotify)g_test_case_free);
+
+  g_free (suite->name);
+
+  g_slist_free_full (suite->suites, (GDestroyNotify)g_test_suite_free);
+
+  g_slice_free (GTestSuite, suite);
+}
+
 static void
 gtest_default_log_handler (const gchar    *log_domain,
                            GLogLevelFlags  log_level,
diff --git a/glib/gtestutils.h b/glib/gtestutils.h
index 2376761d8..5be4ce215 100644
--- a/glib/gtestutils.h
+++ b/glib/gtestutils.h
@@ -509,6 +509,9 @@ int           g_test_run_suite          (GTestSuite     *suite);
 GLIB_AVAILABLE_IN_2_70
 void          g_test_case_free          (GTestCase *test_case);
 
+GLIB_AVAILABLE_IN_2_70
+void          g_test_suite_free         (GTestSuite     *suite);
+
 GLIB_AVAILABLE_IN_ALL
 void    g_test_trap_assertions          (const char     *domain,
                                          const char     *file,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]