[glib: 8/11] tests: Various minor leak fixes in the GObject tests



commit ffb1c3cb74f2547d39229b221962c3d54f287aee
Author: Philip Withnall <withnall endlessm com>
Date:   Wed Jun 27 09:59:18 2018 +0100

    tests: Various minor leak fixes in the GObject tests
    
    Signed-off-by: Philip Withnall <withnall endlessm com>

 gobject/tests/properties.c | 18 +++++++++++-------
 tests/refcount/objects.c   |  1 +
 2 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/gobject/tests/properties.c b/gobject/tests/properties.c
index a1af3f8ba..0aa325a74 100644
--- a/gobject/tests/properties.c
+++ b/gobject/tests/properties.c
@@ -80,7 +80,10 @@ test_object_set_quux (TestObject  *obj,
 static void
 test_object_finalize (GObject *gobject)
 {
-  g_free (((TestObject *) gobject)->baz);
+  TestObject *self = (TestObject *) gobject;
+
+  g_free (self->baz);
+  g_free (self->quux);
 
   /* When the ref_count of an object is zero it is still
    * possible to notify the property, but it should do
@@ -412,6 +415,9 @@ properties_testv_with_valid_properties (void)
   g_assert_cmpstr (g_value_get_string (&values_out[2]), ==, "pigs");
   g_assert_cmpstr (g_value_get_string (&values_out[3]), ==, "fly");
 
+  for (i = 0; i < G_N_ELEMENTS (values_out); i++)
+    g_value_unset (&values_out[i]);
+
   /* Test newv2 && getv */
   g_value_set_string (&(values_in[2]), "Elmo knows");
   g_value_set_string (&(values_in[3]), "where you live");
@@ -425,12 +431,10 @@ properties_testv_with_valid_properties (void)
   g_assert_cmpstr (g_value_get_string (&values_out[2]), ==, "Elmo knows");
   g_assert_cmpstr (g_value_get_string (&values_out[3]), ==, "where you live");
 
-
-  for (i = 0; i < 4; i++)
-    {
-      g_value_unset (&values_in[i]);
-      g_value_unset (&values_out[i]);
-    }
+  for (i = 0; i < G_N_ELEMENTS (values_in); i++)
+    g_value_unset (&values_in[i]);
+  for (i = 0; i < G_N_ELEMENTS (values_out); i++)
+    g_value_unset (&values_out[i]);
 
   g_object_unref (test_obj);
 }
diff --git a/tests/refcount/objects.c b/tests/refcount/objects.c
index 265276901..963766d00 100644
--- a/tests/refcount/objects.c
+++ b/tests/refcount/objects.c
@@ -155,6 +155,7 @@ main (int argc, char **argv)
 
   g_object_unref (test1);
   g_object_unref (test2);
+  g_array_unref (test_threads);
 
   g_print ("stopped\n");
 


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