[glib/wip/gcleanup] tests/gobject: Fix memory leaks in tests
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/gcleanup] tests/gobject: Fix memory leaks in tests
- Date: Sat, 9 Nov 2013 08:24:00 +0000 (UTC)
commit eadc4bcee4a7b67f19f9dc5916182c8ff66b8057
Author: Stef Walter <stefw gnome org>
Date: Fri Nov 8 22:45:23 2013 +0100
tests/gobject: Fix memory leaks in tests
tests/gobject/accumulator.c | 2 ++
tests/gobject/gvalue-test.c | 2 ++
tests/gobject/override.c | 3 +++
tests/gobject/paramspec-test.c | 3 +++
tests/gobject/signals.c | 1 +
tests/gobject/timeloop-closure.c | 14 ++++++++++----
6 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/tests/gobject/accumulator.c b/tests/gobject/accumulator.c
index f8a6c12..f994a76 100644
--- a/tests/gobject/accumulator.c
+++ b/tests/gobject/accumulator.c
@@ -303,5 +303,7 @@ main (int argc,
g_variant_unref (variant_result);
g_assert (variant_finalised);
+ g_object_unref (object);
+
return 0;
}
diff --git a/tests/gobject/gvalue-test.c b/tests/gobject/gvalue-test.c
index fa7bede..b928d8b 100644
--- a/tests/gobject/gvalue-test.c
+++ b/tests/gobject/gvalue-test.c
@@ -355,6 +355,7 @@ test_copying (void)
error = lcopy (&value, &c);
g_assert (error == NULL);
g_assert (strcmp (c, "string ?") == 0);
+ g_free (c);
}
{
@@ -380,6 +381,7 @@ test_copying (void)
g_assert (g_variant_is_of_type (c, G_VARIANT_TYPE ("u")));
g_assert_cmpuint (g_variant_get_uint32 (c), ==, 42);
g_variant_unref (c);
+ g_value_unset (&value);
}
}
diff --git a/tests/gobject/override.c b/tests/gobject/override.c
index 95b4023..47702d7 100644
--- a/tests/gobject/override.c
+++ b/tests/gobject/override.c
@@ -374,6 +374,8 @@ test (GType type,
if (strcmp (ret, expected_retval) != 0)
failed = TRUE;
+
+ g_free (ret);
}
#ifndef VERBOSE
@@ -392,6 +394,7 @@ test (GType type,
}
g_string_free (test_string, TRUE);
+ g_object_unref (self);
}
int
diff --git a/tests/gobject/paramspec-test.c b/tests/gobject/paramspec-test.c
index 129a24f..5b2e834 100644
--- a/tests/gobject/paramspec-test.c
+++ b/tests/gobject/paramspec-test.c
@@ -196,6 +196,7 @@ test_param_spec_override (void)
g_assert (modified && g_value_get_char (&value) == 40);
g_param_spec_unref (pspec);
+ g_param_spec_unref (ospec);
}
static void
@@ -220,6 +221,8 @@ test_param_spec_gtype (void)
g_value_set_gtype (&value, G_TYPE_PARAM_INT);
modified = g_param_value_validate (pspec, &value);
g_assert (!modified && g_value_get_gtype (&value) == G_TYPE_PARAM_INT);
+
+ g_param_spec_unref (pspec);
}
static void
diff --git a/tests/gobject/signals.c b/tests/gobject/signals.c
index 6f5149c..ad1f876 100644
--- a/tests/gobject/signals.c
+++ b/tests/gobject/signals.c
@@ -131,5 +131,6 @@ main (int argc,
g_assert (!callback3_ran);
g_assert (default_handler_ran);
+ g_object_unref (object);
return 0;
}
diff --git a/tests/gobject/timeloop-closure.c b/tests/gobject/timeloop-closure.c
index 13ce760..9de00d3 100644
--- a/tests/gobject/timeloop-closure.c
+++ b/tests/gobject/timeloop-closure.c
@@ -122,9 +122,6 @@ input_callback (GIOChannel *source,
{
g_io_channel_close (source);
g_io_channel_close (dest);
-
- g_io_channel_unref (source);
- g_io_channel_unref (dest);
n_active_children--;
if (n_active_children == 0)
@@ -154,8 +151,15 @@ create_child (void)
source = g_io_create_watch (out_channels[0], G_IO_IN | G_IO_HUP);
g_source_set_closure (source,
- g_cclosure_new (G_CALLBACK (input_callback), in_channels[1], NULL));
+ g_cclosure_new (G_CALLBACK (input_callback), in_channels[1],
+ (GClosureNotify)g_io_channel_unref));
g_source_attach (source, NULL);
+ g_source_unref (source);
+
+ g_io_channel_unref (in_channels[0]);
+ g_io_channel_unref (out_channels[0]);
+ g_io_channel_unref (out_channels[1]);
+
}
else if (pid == 0) /* Child */
{
@@ -216,5 +220,7 @@ main (int argc, char **argv)
difftimeval (&old_usage.ru_stime, &new_usage.ru_stime)) /
(n_iters * n_children));
+ g_main_loop_unref (loop);
+
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]