From 5bb2c1c62a06e682ab48d530cae5f9614a90a75e Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 16 Nov 2011 15:31:29 +0100 Subject: Use _unref instead of _free _destroy when possible.unref Replace g_(ptr_)array_free (foo, TRUE) and g_hash_table_destroy with respectively g_(ptr_)array_unref (foo) and g_hash_table_unref. I used this command to generate this patch: for f in `find -name "*.c"`; do sed -i $f -re 's/g_ptr_array_free \(([^ ,]+), TRUE\)/g_ptr_array_unref \(\1\)/'; done See Danielle's blog for explanation of possible bug _free can do: http://blogs.gnome.org/danni/2011/11/16/mistakes-with-g_value_set_boxed/ --- libempathy/empathy-account-settings.c | 6 +++--- libempathy/empathy-contact-manager.c | 2 +- libempathy/empathy-debug.c | 2 +- libempathy/empathy-ft-handler.c | 4 ++-- libempathy/empathy-individual-manager.c | 4 ++-- libempathy/empathy-irc-network-manager.c | 2 +- libempathy/empathy-tp-chat.c | 4 ++-- libempathy/empathy-tp-contact-list.c | 20 ++++++++++---------- libempathy/empathy-tp-file.c | 2 +- libempathy/empathy-tp-roomlist.c | 2 +- libempathy/empathy-tp-streamed-media.c | 2 +- 11 files changed, 25 insertions(+), 25 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-account-settings.c b/libempathy/empathy-account-settings.c index cd6b69e8c..78d609685 100644 --- a/libempathy/empathy-account-settings.c +++ b/libempathy/empathy-account-settings.c @@ -402,11 +402,11 @@ empathy_account_settings_finalize (GObject *object) g_list_free (priv->required_params); } - g_hash_table_destroy (priv->parameters); - g_hash_table_destroy (priv->param_regexps); + g_hash_table_unref (priv->parameters); + g_hash_table_unref (priv->param_regexps); empathy_account_settings_free_unset_parameters (self); - g_array_free (priv->unset_parameters, TRUE); + g_array_unref (priv->unset_parameters); G_OBJECT_CLASS (empathy_account_settings_parent_class)->finalize (object); } diff --git a/libempathy/empathy-contact-manager.c b/libempathy/empathy-contact-manager.c index 88012bf35..31750dcfe 100644 --- a/libempathy/empathy-contact-manager.c +++ b/libempathy/empathy-contact-manager.c @@ -198,7 +198,7 @@ contact_manager_finalize (GObject *object) g_hash_table_foreach (priv->lists, contact_manager_disconnect_foreach, object); - g_hash_table_destroy (priv->lists); + g_hash_table_unref (priv->lists); g_object_unref (priv->account_manager); } diff --git a/libempathy/empathy-debug.c b/libempathy/empathy-debug.c index 4f624f8e1..9e34ac1db 100644 --- a/libempathy/empathy-debug.c +++ b/libempathy/empathy-debug.c @@ -111,7 +111,7 @@ empathy_debug_free (void) if (flag_to_keys == NULL) return; - g_hash_table_destroy (flag_to_keys); + g_hash_table_unref (flag_to_keys); flag_to_keys = NULL; } diff --git a/libempathy/empathy-ft-handler.c b/libempathy/empathy-ft-handler.c index facc49a3b..3d6525240 100644 --- a/libempathy/empathy-ft-handler.c +++ b/libempathy/empathy-ft-handler.c @@ -1054,7 +1054,7 @@ set_content_hash_type_from_classes (EmpathyFTHandler *handler, if (!support_ft) { - g_array_free (possible_values, TRUE); + g_array_unref (possible_values); return FALSE; } @@ -1087,7 +1087,7 @@ set_content_hash_type_from_classes (EmpathyFTHandler *handler, } out: - g_array_free (possible_values, TRUE); + g_array_unref (possible_values); DEBUG ("Hash enabled %s; setting content hash type as %u", priv->use_hash ? "True" : "False", priv->content_hash_type); diff --git a/libempathy/empathy-individual-manager.c b/libempathy/empathy-individual-manager.c index 044610724..5305c41e8 100644 --- a/libempathy/empathy-individual-manager.c +++ b/libempathy/empathy-individual-manager.c @@ -249,7 +249,7 @@ individual_manager_dispose (GObject *object) { EmpathyIndividualManagerPriv *priv = GET_PRIV (object); - g_hash_table_destroy (priv->individuals); + g_hash_table_unref (priv->individuals); g_signal_handlers_disconnect_by_func (priv->aggregator, aggregator_individuals_changed_cb, object); @@ -470,7 +470,7 @@ empathy_individual_manager_add_from_contact (EmpathyIndividualManager *self, priv->aggregator, NULL, persona_store, details, aggregator_add_persona_from_details_cb, contact); - g_hash_table_destroy (details); + g_hash_table_unref (details); g_object_unref (persona_store); finish: diff --git a/libempathy/empathy-irc-network-manager.c b/libempathy/empathy-irc-network-manager.c index 6d7ff1c3d..a9d89dca9 100644 --- a/libempathy/empathy-irc-network-manager.c +++ b/libempathy/empathy-irc-network-manager.c @@ -155,7 +155,7 @@ empathy_irc_network_manager_finalize (GObject *object) g_free (priv->global_file); g_free (priv->user_file); - g_hash_table_destroy (priv->networks); + g_hash_table_unref (priv->networks); G_OBJECT_CLASS (empathy_irc_network_manager_parent_class)->finalize (object); } diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index 087090ad4..d34f581ef 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -762,7 +762,7 @@ tp_chat_finalize (GObject *object) g_queue_free (self->priv->messages_queue); g_queue_free (self->priv->pending_messages_queue); - g_hash_table_destroy (self->priv->messages_being_sent); + g_hash_table_unref (self->priv->messages_being_sent); g_free (self->priv->title); g_free (self->priv->subject); @@ -1441,7 +1441,7 @@ empathy_tp_chat_join (EmpathyTpChat *self) tp_cli_channel_interface_group_call_add_members ((TpChannel *) self, -1, members, "", add_members_cb, NULL, NULL, G_OBJECT (self)); - g_array_free (members, TRUE); + g_array_unref (members); } gboolean diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c index bf639e4ce..055154564 100644 --- a/libempathy/empathy-tp-contact-list.c +++ b/libempathy/empathy-tp-contact-list.c @@ -273,7 +273,7 @@ tp_contact_list_group_ready_cb (TpChannel *channel, g_assert (members != NULL); arr = tp_intset_to_array (members); contacts_added_to_group (list, channel, arr); - g_array_free (arr, TRUE); + g_array_unref (arr); } static void @@ -354,7 +354,7 @@ tp_contact_list_group_add (EmpathyTpContactList *list, if (channel) { tp_cli_channel_interface_group_call_add_members (channel, -1, handles, NULL, NULL, NULL, NULL, NULL); - g_array_free (handles, TRUE); + g_array_unref (handles); return; } @@ -434,7 +434,7 @@ add_to_members (EmpathyTpContactList *list, got_added_members_cb, NULL, NULL, G_OBJECT (list)); } - g_array_free (request, TRUE); + g_array_unref (request); } static void @@ -684,7 +684,7 @@ tp_contact_list_subscribe_group_members_changed_cb (TpChannel *channel, tp_cli_channel_interface_group_call_add_members (priv->publish, -1, accept, NULL, NULL, NULL, NULL, NULL); - g_array_free (accept, TRUE); + g_array_unref (accept); } static void @@ -740,10 +740,10 @@ tp_contact_list_finalize (GObject *object) tp_contact_list_group_invalidated_cb, list); } - g_hash_table_destroy (priv->groups); - g_hash_table_destroy (priv->members); - g_hash_table_destroy (priv->pendings); - g_hash_table_destroy (priv->add_to_group); + g_hash_table_unref (priv->groups); + g_hash_table_unref (priv->members); + g_hash_table_unref (priv->pendings); + g_hash_table_unref (priv->add_to_group); G_OBJECT_CLASS (empathy_tp_contact_list_parent_class)->finalize (object); } @@ -1016,7 +1016,7 @@ empathy_tp_contact_list_class_init (EmpathyTpContactListClass *klass) static void tp_contact_list_array_free (gpointer handles) { - g_array_free (handles, TRUE); + g_array_unref (handles); } static void @@ -1281,7 +1281,7 @@ tp_contact_list_remove_group (EmpathyContactList *list, tp_cli_channel_interface_group_call_remove_members (channel, -1, handles, NULL, NULL, NULL, NULL, NULL); tp_cli_channel_call_close (channel, -1, NULL, NULL, NULL, NULL); - g_array_free (handles, TRUE); + g_array_unref (handles); } static EmpathyContactListFlags diff --git a/libempathy/empathy-tp-file.c b/libempathy/empathy-tp-file.c index ff2099ee9..c5c9f0cdd 100644 --- a/libempathy/empathy-tp-file.c +++ b/libempathy/empathy-tp-file.c @@ -705,7 +705,7 @@ do_finalize (GObject *object) if (self->priv->socket_address != NULL) { - g_array_free (self->priv->socket_address, TRUE); + g_array_unref (self->priv->socket_address); self->priv->socket_address = NULL; } diff --git a/libempathy/empathy-tp-roomlist.c b/libempathy/empathy-tp-roomlist.c index 1e53facdc..93e28d3d3 100644 --- a/libempathy/empathy-tp-roomlist.c +++ b/libempathy/empathy-tp-roomlist.c @@ -203,7 +203,7 @@ tp_roomlist_got_rooms_cb (TpChannel *channel, chatrooms, tp_roomlist_chatrooms_free, list); - g_array_free (handles, TRUE); + g_array_unref (handles); } } diff --git a/libempathy/empathy-tp-streamed-media.c b/libempathy/empathy-tp-streamed-media.c index 87ca01db5..388b3aa00 100644 --- a/libempathy/empathy-tp-streamed-media.c +++ b/libempathy/empathy-tp-streamed-media.c @@ -261,7 +261,7 @@ tp_streamed_media_request_streams_for_capabilities (EmpathyTpStreamedMedia *call handle, stream_types, tp_streamed_media_request_streams_cb, NULL, NULL, G_OBJECT (call)); - g_array_free (stream_types, TRUE); + g_array_unref (stream_types); } static void -- cgit v1.2.3