]> git.0d.be Git - empathy.git/commitdiff
Use _unref instead of _free _destroy when possible.unref
authorXavier Claessens <xclaesse@gmail.com>
Wed, 16 Nov 2011 14:31:29 +0000 (15:31 +0100)
committerXavier Claessens <xclaesse@gmail.com>
Wed, 16 Nov 2011 14:57:00 +0000 (15:57 +0100)
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/

31 files changed:
goa-mc-plugin/mcp-account-manager-goa.c
libempathy-gtk/empathy-contact-list-store.c
libempathy-gtk/empathy-contact-search-dialog.c
libempathy-gtk/empathy-contactinfo-utils.c
libempathy-gtk/empathy-individual-linker.c
libempathy-gtk/empathy-individual-menu.c
libempathy-gtk/empathy-individual-store.c
libempathy-gtk/empathy-individual-view.c
libempathy-gtk/empathy-individual-widget.c
libempathy-gtk/empathy-notify-manager.c
libempathy-gtk/empathy-persona-store.c
libempathy-gtk/empathy-protocol-chooser.c
libempathy-gtk/empathy-spell.c
libempathy/empathy-account-settings.c
libempathy/empathy-contact-manager.c
libempathy/empathy-debug.c
libempathy/empathy-ft-handler.c
libempathy/empathy-individual-manager.c
libempathy/empathy-irc-network-manager.c
libempathy/empathy-tp-chat.c
libempathy/empathy-tp-contact-list.c
libempathy/empathy-tp-file.c
libempathy/empathy-tp-roomlist.c
libempathy/empathy-tp-streamed-media.c
src/empathy-debug-window.c
src/empathy-ft-manager.c
src/empathy-import-utils.c
src/empathy-main-window.c
src/empathy-map-view.c
tests/empathy-chatroom-manager-test.c
tests/empathy-tls-test.c

index 1185d7ba31ef4a55ce68e5c7e482571698b06975..fd3942eaf359df2be0f1cb553828cc9b7ac9cbe1 100644 (file)
@@ -82,7 +82,7 @@ mcp_account_manager_goa_finalize (GObject *self)
 {
   McpAccountManagerGoaPrivate *priv = GET_PRIVATE (self);
 
-  g_hash_table_destroy (priv->accounts);
+  g_hash_table_unref (priv->accounts);
   g_key_file_free (priv->store);
   g_free (priv->filename);
 
@@ -150,7 +150,7 @@ get_tp_parameters (GoaAccount *account)
   else
     {
       DEBUG ("Unknown account type %s", type);
-      g_hash_table_destroy (params);
+      g_hash_table_unref (params);
       return NULL;
     }
 
@@ -179,7 +179,7 @@ get_tp_account_name (GoaAccount *account)
       (char *) g_hash_table_lookup (params, "protocol"),
       type, id);
 
-  g_hash_table_destroy (params);
+  g_hash_table_unref (params);
 
   return name;
 }
@@ -399,7 +399,7 @@ mcp_account_manager_goa_get (const McpAccountStorage *self,
       while (g_hash_table_iter_next (&iter, &key, &value))
         mcp_account_manager_set_value (am, acct, key, value);
 
-      g_hash_table_destroy (params);
+      g_hash_table_unref (params);
 
       /* Stored properties */
       keys = g_key_file_get_keys (priv->store, acct, &nkeys, NULL);
@@ -439,7 +439,7 @@ mcp_account_manager_goa_get (const McpAccountStorage *self,
 
       mcp_account_manager_set_value (am, acct, key, value);
 
-      g_hash_table_destroy (params);
+      g_hash_table_unref (params);
       g_free (value);
     }
 
index ef4c466b315793468f9a416a643a96852a9e218b..359e6c1b60100999ae1425c97e1d3594c56c781e 100644 (file)
@@ -386,9 +386,9 @@ contact_list_store_dispose (GObject *object)
                priv->setup_idle_id = 0;
        }
 
-       g_hash_table_destroy (priv->status_icons);
-       g_hash_table_destroy (priv->empathy_contact_cache);
-       g_hash_table_destroy (priv->empathy_group_cache);
+       g_hash_table_unref (priv->status_icons);
+       g_hash_table_unref (priv->empathy_contact_cache);
+       g_hash_table_unref (priv->empathy_group_cache);
        G_OBJECT_CLASS (empathy_contact_list_store_parent_class)->dispose (object);
 }
 
index 1dfb942e266fa62afd323b0ec679f9ca4474f82f..174f0441d1c66f92ceee66dcd8f701711ad6178c 100644 (file)
@@ -120,7 +120,7 @@ on_searcher_reset (GObject *source_object,
   gtk_list_store_clear (priv->store);
   tp_contact_search_start (priv->searcher, search);
 
-  g_hash_table_destroy (search);
+  g_hash_table_unref (search);
 }
 
 static void
index 9d07f3fa1c1a4489f3ac389b71615d9980f39d9a..695d1ee3c8a2ccf057ef18aeed422ecbbfc530c4 100644 (file)
@@ -206,7 +206,7 @@ build_parameters_string (GStrv parameters)
   g_ptr_array_add (output, NULL); /* NULL-terminate */
 
   join = g_strjoinv (", ", (char **) output->pdata);
-  g_ptr_array_free (output, TRUE);
+  g_ptr_array_unref (output);
 
   return join;
 }
index 793c2827fa09a4d30f03f281f6db161a71fd597f..c39ed23091f0babaef213d8ce1c766eb1b2dce75 100644 (file)
@@ -572,7 +572,7 @@ finalize (GObject *object)
 {
   EmpathyIndividualLinkerPriv *priv = GET_PRIV (object);
 
-  g_hash_table_destroy (priv->changed_individuals);
+  g_hash_table_unref (priv->changed_individuals);
 
   G_OBJECT_CLASS (empathy_individual_linker_parent_class)->finalize (object);
 }
index 2209e1538915861cf476bdda6c256f5782b72d6b..27b2c67c2e27840cfc633d2bff6fc69c5b1e995f 100644 (file)
@@ -1420,7 +1420,7 @@ empathy_individual_invite_menu_item_new (FolksIndividual *individual,
 
   gtk_widget_show (image);
 
-  g_hash_table_destroy (name_room_map);
+  g_hash_table_unref (name_room_map);
   g_object_unref (mgr);
   g_list_free (names);
   g_list_free (rooms);
index 630d8d284f9346abafd5c836eeb3f1f122edb29e..da0ee871f923e1864f907a6a480c7954b5685b86 100644 (file)
@@ -1080,9 +1080,9 @@ individual_store_dispose (GObject *object)
       g_source_remove (self->priv->setup_idle_id);
     }
 
-  g_hash_table_destroy (self->priv->status_icons);
-  g_hash_table_destroy (self->priv->folks_individual_cache);
-  g_hash_table_destroy (self->priv->empathy_group_cache);
+  g_hash_table_unref (self->priv->status_icons);
+  g_hash_table_unref (self->priv->folks_individual_cache);
+  g_hash_table_unref (self->priv->empathy_group_cache);
   G_OBJECT_CLASS (empathy_individual_store_parent_class)->dispose (object);
 }
 
index 440680b2042bb84569e2c07e81398724b75f8461..3cd1500a8b496d3ff4fb4f0a4ca14fb4d637d1e2 100644 (file)
@@ -2054,7 +2054,7 @@ individual_view_finalize (GObject *object)
 
   if (priv->expand_groups_idle_handler != 0)
     g_source_remove (priv->expand_groups_idle_handler);
-  g_hash_table_destroy (priv->expand_groups);
+  g_hash_table_unref (priv->expand_groups);
 
   G_OBJECT_CLASS (empathy_individual_view_parent_class)->finalize (object);
 }
index 4883c62e79cf3342c85aee6058ee0cfb29bd1564..08c1c1c6ba463ab972549aecd6d21f93acab14eb 100644 (file)
@@ -2088,7 +2088,7 @@ finalize (GObject *object)
 {
   EmpathyIndividualWidgetPriv *priv = GET_PRIV (object);
 
-  g_hash_table_destroy (priv->persona_grids);
+  g_hash_table_unref (priv->persona_grids);
 
   G_OBJECT_CLASS (empathy_individual_widget_parent_class)->finalize (object);
 }
index 3fcf9afb7182ab167a7d81635e10f619693384fc..bccc3e21e87ce89df74f91a2215c33d47dc4e8de 100644 (file)
@@ -89,7 +89,7 @@ notify_manager_finalize (GObject *object)
 {
   EmpathyNotifyManagerPriv *priv = GET_PRIV (object);
 
-  g_hash_table_destroy (priv->capabilities);
+  g_hash_table_unref (priv->capabilities);
 
   G_OBJECT_CLASS (empathy_notify_manager_parent_class)->finalize (object);
 }
index 70d53b3c1581194f283ab04a8859f14e682275ab..a48fa121e59ddd1a2808937c7b74686fadfa9c63 100644 (file)
@@ -898,8 +898,8 @@ finalize (GObject *object)
 {
   EmpathyPersonaStorePriv *priv = GET_PRIV (object);
 
-  g_hash_table_destroy (priv->status_icons);
-  g_hash_table_destroy (priv->personas);
+  g_hash_table_unref (priv->status_icons);
+  g_hash_table_unref (priv->personas);
 
   G_OBJECT_CLASS (empathy_persona_store_parent_class)->finalize (object);
 }
index 46188d499abf1939e3debec251cc1a43b622fa2b..216e4ffdb96f190b541a9377bb88274dd5b67cc7 100644 (file)
@@ -365,7 +365,7 @@ protocol_chooser_finalize (GObject *object)
 
   if (priv->protocols)
     {
-      g_hash_table_destroy (priv->protocols);
+      g_hash_table_unref (priv->protocols);
       priv->protocols = NULL;
     }
 
index d097f1eeb93fb8f155bcc9e992ea6ddb9633963c..fb1441e6f3446740d905945f0c1c7a4fec7e8e62 100644 (file)
@@ -169,7 +169,7 @@ spell_notify_languages_cb (GSettings   *gsettings,
 
        /* We just reset the languages list. */
        if (languages != NULL) {
-               g_hash_table_destroy (languages);
+               g_hash_table_unref (languages);
                languages = NULL;
        }
 }
index cd6b69e8c2a3b9b8da34f1c68a59c9741a9e7e56..78d609685b04753ac179a2853038da014ffe8d6a 100644 (file)
@@ -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);
 }
index 88012bf35f0abcd49ccf4cdfd9d29eb2a35e2fe1..31750dcfe00173a759d4d4fb97f6c8d76d6e4730 100644 (file)
@@ -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);
 }
index 4f624f8e198016bbfcac087215e5c70c1712752a..9e34ac1db47e99d6b21faeee12ba84e92d07dc15 100644 (file)
@@ -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;
 }
 
index facc49a3b77bdc534e0951606e75138af1d78810..3d652524061bb2557228c838c1d12f1cd921725a 100644 (file)
@@ -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);
index 0446107247e939c834a9c10a05403b0f53a73d4e..5305c41e8ba1773626d5d8d2f20252fceff3ee8c 100644 (file)
@@ -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:
index 6d7ff1c3d0ffbc75222efeabd87122e0a9b6e9da..a9d89dca95796667e1e5acb61affe721754f9452 100644 (file)
@@ -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);
 }
index 087090ad4f38dbcdf39a46eb1d56c2ec4e15debc..d34f581ef75c36b684e69db7c4d7bbe658742d49 100644 (file)
@@ -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
index bf639e4cee98ca7279ef5d4a9485ddc879dcd740..05515456403627e0fb7b926c6d76a5df2678a021 100644 (file)
@@ -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
index ff2099ee90919e1c199aea9955a75bc1dde63745..c5c9f0cdd1f837f3ed2943459c239bcf69769f73 100644 (file)
@@ -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;
     }
 
index 1e53facdcd11bdcc57e33e4c81a3deeefcf0f031..93e28d3d3b150a48b8a48151e33c55bb9241190c 100644 (file)
@@ -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);
        }
 }
 
index 87ca01db57149eab0cb2344c183d4461be89657e..388b3aa0005d1c254a47a2e1a4e1600d585a263d 100644 (file)
@@ -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
index 294c6afe089fbee321c81b848b1c515da6948e8e..80dad106aa44ffe8863da5351ca02154656d5bd3 100644 (file)
@@ -631,7 +631,7 @@ get_cm_display_name (EmpathyDebugWindow *self,
       retval = g_strdup (cm_name);
     }
 
-  g_hash_table_destroy (protocols);
+  g_hash_table_unref (protocols);
 
   return retval;
 }
@@ -1721,7 +1721,7 @@ debug_window_finalize (GObject *object)
       debug_message_list_free (values);
     }
 
-  g_hash_table_destroy (priv->cache);
+  g_hash_table_unref (priv->cache);
 
   (G_OBJECT_CLASS (empathy_debug_window_parent_class)->finalize) (object);
 }
index 5d2f659f2ec85573d655ac491d9a16854dff0e40..606600e990aad239801bdbd1a848e86f7a817e26 100644 (file)
@@ -1082,7 +1082,7 @@ empathy_ft_manager_finalize (GObject *object)
 
   DEBUG ("FT Manager %p", object);
 
-  g_hash_table_destroy (priv->ft_handler_to_row_ref);
+  g_hash_table_unref (priv->ft_handler_to_row_ref);
 
   G_OBJECT_CLASS (empathy_ft_manager_parent_class)->finalize (object);
 }
index bf7f29e3ba7faeb24fd38be06795d49efc2182b9..0c878e8f6aeb6c2915508fbe225c009060450e80 100644 (file)
@@ -55,7 +55,7 @@ empathy_import_account_data_free (EmpathyImportAccountData *data)
   if (data->connection_manager != NULL)
     g_free (data->connection_manager);
   if (data->settings != NULL)
-    g_hash_table_destroy (data->settings);
+    g_hash_table_unref (data->settings);
   if (data->source != NULL)
     g_free (data->source);
 
index 367ae067f6b9829f331ce73359c30fc1be7fd109..0e4b8bae52e1ac8955b5007b53447236f2204834 100644 (file)
@@ -1372,8 +1372,8 @@ empathy_main_window_finalize (GObject *window)
        g_object_unref (priv->individual_store);
        g_object_unref (priv->contact_manager);
        g_object_unref (priv->sound_mgr);
-       g_hash_table_destroy (priv->errors);
-       g_hash_table_destroy (priv->auths);
+       g_hash_table_unref (priv->errors);
+       g_hash_table_unref (priv->auths);
 
        /* disconnect all handlers of status-changed signal */
        g_hash_table_iter_init (&iter, priv->status_changed_handlers);
@@ -1381,7 +1381,7 @@ empathy_main_window_finalize (GObject *window)
                g_signal_handler_disconnect (TP_ACCOUNT (key),
                                             GPOINTER_TO_UINT (value));
 
-       g_hash_table_destroy (priv->status_changed_handlers);
+       g_hash_table_unref (priv->status_changed_handlers);
 
        g_signal_handlers_disconnect_by_func (priv->event_manager,
                                              main_window_event_added_cb,
index 9e6cc6dee0e7be7e0c2e4f286dd8e6771379f844..72aab0b2cd61352fa3b3d3584c2f8ec51d331777 100644 (file)
@@ -412,7 +412,7 @@ empathy_map_view_finalize (GObject *object)
   g_signal_handler_disconnect (priv->contact_list,
       priv->members_changed_id);
 
-  g_hash_table_destroy (priv->markers);
+  g_hash_table_unref (priv->markers);
   g_object_unref (priv->contact_list);
   g_object_unref (priv->layer);
 
index 966027f385a890df07bbf6bd4156df88a215a80b..3ba0239f1208f0817954743b54c5974bb8215b6f 100644 (file)
@@ -76,7 +76,7 @@ check_chatrooms_list (EmpathyChatroomManager *mgr,
   fail_if (g_hash_table_size (found) != 0);
 
   g_list_free (chatrooms);
-  g_hash_table_destroy (found);
+  g_hash_table_unref (found);
 }
 
 static gboolean
index f2b667d0bf0aa84bb48906e6bffb9aabf12280c9..8256da477aab72945ff2a7ad0bf9797f05c848ed 100644 (file)
@@ -102,7 +102,7 @@ mock_tls_certificate_finalize (GObject *object)
       &self->rejections);
   g_free (self->cert_type);
   self->cert_type = NULL;
-  g_ptr_array_free (self->cert_data, TRUE);
+  g_ptr_array_unref (self->cert_data);
   self->cert_data = NULL;
 
   G_OBJECT_CLASS (mock_tls_certificate_parent_class)->finalize (object);
@@ -226,7 +226,7 @@ mock_tls_certificate_assert_rejected (MockTLSCertificate *self,
               TP_HASH_TYPE_STRING_VARIANT_MAP, &rejection_details,
               NULL);
       g_free (rejection_error);
-      g_hash_table_destroy (rejection_details);
+      g_hash_table_unref (rejection_details);
 
       if (rejection_reason == reason)
         return;