From 73ff53f5b38ba6ce3ad75e94f96d40b7fac644f3 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 10 Mar 2014 17:50:26 +0000 Subject: [PATCH 09/23] TpTestsSimpleChannelDispatcher: don't leak various struct members --- tests/lib/simple-channel-dispatcher.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/lib/simple-channel-dispatcher.c b/tests/lib/simple-channel-dispatcher.c index 775f915..49516bb 100644 --- a/tests/lib/simple-channel-dispatcher.c +++ b/tests/lib/simple-channel-dispatcher.c @@ -335,13 +335,26 @@ tp_tests_simple_channel_dispatcher_dispose (GObject *object) g_slist_foreach (self->priv->requests, (GFunc) g_object_unref, NULL); g_slist_free (self->priv->requests); - g_free (self->priv->old_handler); - if (G_OBJECT_CLASS (tp_tests_simple_channel_dispatcher_parent_class)->dispose != NULL) G_OBJECT_CLASS (tp_tests_simple_channel_dispatcher_parent_class)->dispose (object); } static void +tp_tests_simple_channel_dispatcher_finalize (GObject *object) +{ + TpTestsSimpleChannelDispatcher *self = SIMPLE_CHANNEL_DISPATCHER (object); + + g_clear_pointer (&self->last_request, g_hash_table_unref); + g_clear_pointer (&self->last_hints, g_hash_table_unref); + g_free (self->last_account); + g_free (self->last_preferred_handler); + g_free (self->priv->old_handler); + + if (G_OBJECT_CLASS (tp_tests_simple_channel_dispatcher_parent_class)->finalize != NULL) + G_OBJECT_CLASS (tp_tests_simple_channel_dispatcher_parent_class)->finalize (object); +} + +static void tp_tests_simple_channel_dispatcher_class_init ( TpTestsSimpleChannelDispatcherClass *klass) { @@ -367,6 +380,7 @@ tp_tests_simple_channel_dispatcher_class_init ( object_class->set_property = tp_tests_simple_channel_dispatcher_set_property; object_class->dispose = tp_tests_simple_channel_dispatcher_dispose; + object_class->finalize = tp_tests_simple_channel_dispatcher_finalize; param_spec = g_param_spec_boxed ("interfaces", "Extra D-Bus interfaces", "In this case we only implement ChannelDispatcher, so none.", -- 1.9.0