tests: Various minor leak fixes in the GObject tests

Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
Philip Withnall 2018-06-27 09:59:18 +01:00
parent 6a22663d9a
commit ffb1c3cb74
2 changed files with 12 additions and 7 deletions

View File

@ -80,7 +80,10 @@ test_object_set_quux (TestObject *obj,
static void static void
test_object_finalize (GObject *gobject) 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 /* When the ref_count of an object is zero it is still
* possible to notify the property, but it should do * 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[2]), ==, "pigs");
g_assert_cmpstr (g_value_get_string (&values_out[3]), ==, "fly"); 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 */ /* Test newv2 && getv */
g_value_set_string (&(values_in[2]), "Elmo knows"); g_value_set_string (&(values_in[2]), "Elmo knows");
g_value_set_string (&(values_in[3]), "where you live"); 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[2]), ==, "Elmo knows");
g_assert_cmpstr (g_value_get_string (&values_out[3]), ==, "where you live"); g_assert_cmpstr (g_value_get_string (&values_out[3]), ==, "where you live");
for (i = 0; i < G_N_ELEMENTS (values_in); i++)
for (i = 0; i < 4; i++)
{
g_value_unset (&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_value_unset (&values_out[i]);
}
g_object_unref (test_obj); g_object_unref (test_obj);
} }

View File

@ -155,6 +155,7 @@ main (int argc, char **argv)
g_object_unref (test1); g_object_unref (test1);
g_object_unref (test2); g_object_unref (test2);
g_array_unref (test_threads);
g_print ("stopped\n"); g_print ("stopped\n");