diff options
author | Xavier Claessens <xclaesse@gmail.com> | 2011-11-16 16:07:25 +0100 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2011-11-16 16:07:25 +0100 |
commit | ee2090321ca1530ada26c5431b9ba3dacfd4ea07 (patch) | |
tree | db9a88fe1e3b7e983c3ee08e13b50598931e8d2f | |
parent | 3e39bb0e14bcbbefcb98839e730d86864165f28b (diff) |
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/
-rw-r--r-- | src/client-registry.c | 2 | ||||
-rw-r--r-- | src/mcd-account-compat.c | 2 | ||||
-rw-r--r-- | src/mcd-account-manager-query.c | 6 | ||||
-rw-r--r-- | src/mcd-account-manager.c | 2 | ||||
-rw-r--r-- | src/mcd-account.c | 6 | ||||
-rw-r--r-- | src/mcd-channel.c | 2 | ||||
-rw-r--r-- | src/mcd-client.c | 10 | ||||
-rw-r--r-- | src/mcd-connection.c | 18 | ||||
-rw-r--r-- | src/mcd-dbusprop.c | 2 | ||||
-rw-r--r-- | src/mcd-dispatch-operation.c | 2 | ||||
-rw-r--r-- | src/mcd-dispatcher.c | 8 | ||||
-rw-r--r-- | src/mcd-handler-map.c | 10 | ||||
-rw-r--r-- | src/mcd-master.c | 4 | ||||
-rw-r--r-- | src/mcd-provisioning-factory.c | 2 |
14 files changed, 38 insertions, 38 deletions
diff --git a/src/client-registry.c b/src/client-registry.c index 8b96bce5..dc58f640 100644 --- a/src/client-registry.c +++ b/src/client-registry.c @@ -478,7 +478,7 @@ mcd_client_registry_dispose (GObject *object) } - tp_clear_pointer (&self->priv->clients, g_hash_table_destroy); + tp_clear_pointer (&self->priv->clients, g_hash_table_unref); if (chain_up != NULL) chain_up (object); diff --git a/src/mcd-account-compat.c b/src/mcd-account-compat.c index ab8995f6..69893c8e 100644 --- a/src/mcd-account-compat.c +++ b/src/mcd-account-compat.c @@ -61,7 +61,7 @@ emit_compat_property_changed (McdAccount *account, const gchar *key, mc_svc_account_interface_compat_emit_compat_property_changed (account, properties); - g_hash_table_destroy (properties); + g_hash_table_unref (properties); } static void diff --git a/src/mcd-account-manager-query.c b/src/mcd-account-manager-query.c index 95e0068d..ca0f34d6 100644 --- a/src/mcd-account-manager-query.c +++ b/src/mcd-account-manager-query.c @@ -335,14 +335,14 @@ account_manager_find_accounts (McSvcAccountManagerInterfaceQuery *self, accounts = _mcd_account_manager_get_accounts (account_manager); g_hash_table_foreach (accounts, find_accounts, &fd); } - g_array_free (fd.params, TRUE); + g_array_unref (fd.params); for (i = 0; i < fd.properties->len; i++) { McdIfaceProperty *prop; prop = &g_array_index (fd.properties, McdIfaceProperty, i); g_free (prop->iface); } - g_array_free (fd.properties, TRUE); + g_array_unref (fd.properties); if (fd.error) { @@ -353,7 +353,7 @@ account_manager_find_accounts (McSvcAccountManagerInterfaceQuery *self, mc_svc_account_manager_interface_query_return_from_find_accounts (context, fd.accounts); - g_ptr_array_free (fd.accounts, TRUE); + g_ptr_array_unref (fd.accounts); } diff --git a/src/mcd-account-manager.c b/src/mcd-account-manager.c index c49a8e75..7714c137 100644 --- a/src/mcd-account-manager.c +++ b/src/mcd-account-manager.c @@ -1298,7 +1298,7 @@ _mcd_account_manager_finalize (GObject *object) remove (priv->account_connections_file); g_free (priv->account_connections_file); - g_hash_table_destroy (priv->accounts); + g_hash_table_unref (priv->accounts); G_OBJECT_CLASS (mcd_account_manager_parent_class)->finalize (object); } diff --git a/src/mcd-account.c b/src/mcd-account.c index a0ddf898..c4a7eb6e 100644 --- a/src/mcd-account.c +++ b/src/mcd-account.c @@ -542,7 +542,7 @@ account_external_password_storage_get_accounts_cb (TpProxy *cm, props, NULL); - g_hash_table_destroy (props); + g_hash_table_unref (props); } static void @@ -2898,7 +2898,7 @@ _mcd_account_finalize (GObject *object) DEBUG ("%p (%s)", object, priv->unique_name); if (priv->changed_properties) - g_hash_table_destroy (priv->changed_properties); + g_hash_table_unref (priv->changed_properties); if (priv->properties_source != 0) g_source_remove (priv->properties_source); @@ -4193,7 +4193,7 @@ mcd_account_connection_ready_cb (McdAccount *account, mcd_account_self_handle_inspected_cb, NULL, NULL, (GObject *) account); - g_array_free (self_handle_array, TRUE); + g_array_unref (self_handle_array); /* FIXME: ideally, on protocols with server-stored nicknames, this should * only be done if the local Nickname has been changed since last time we diff --git a/src/mcd-channel.c b/src/mcd-channel.c index e6c23d82..59f9df41 100644 --- a/src/mcd-channel.c +++ b/src/mcd-channel.c @@ -1418,7 +1418,7 @@ mcd_channel_ready_to_depart_cb (TpChannel *channel, channel, -1, a, d->message, d->reason, mcd_channel_depart_cb, NULL, NULL, NULL); - g_array_free (a, TRUE); + g_array_unref (a); g_free (d->message); g_slice_free (DepartData, d); } diff --git a/src/mcd-client.c b/src/mcd-client.c index 8ab492d9..fceba819 100644 --- a/src/mcd-client.c +++ b/src/mcd-client.c @@ -494,7 +494,7 @@ _mcd_client_proxy_set_filters (McdClientProxy *client, client_filters = g_list_prepend (client_filters, new_channel_class); else - g_hash_table_destroy (new_channel_class); + g_hash_table_unref (new_channel_class); } switch (interface) @@ -634,8 +634,8 @@ _mcd_client_recover_observer (McdClientProxy *self, TpChannel *channel, NULL, NULL, NULL, NULL); _mcd_tp_channel_details_free (channels_array); - g_ptr_array_free (satisfied_requests, TRUE); - g_hash_table_destroy (observer_info); + g_ptr_array_unref (satisfied_requests); + g_hash_table_unref (observer_info); } static void @@ -1367,7 +1367,7 @@ mcd_client_proxy_free_client_filters (GList **client_filters) if (*client_filters != NULL) { - g_list_foreach (*client_filters, (GFunc) g_hash_table_destroy, NULL); + g_list_foreach (*client_filters, (GFunc) g_hash_table_unref, NULL); g_list_free (*client_filters); *client_filters = NULL; } @@ -1786,6 +1786,6 @@ _mcd_client_proxy_handle_channels (McdClientProxy *self, callback, user_data, destroy, weak_object); _mcd_tp_channel_details_free (channel_details); - g_ptr_array_free (requests_satisfied, TRUE); + g_ptr_array_unref (requests_satisfied); g_hash_table_unref (handler_info); } diff --git a/src/mcd-connection.c b/src/mcd-connection.c index 4b276333..7f8b9a85 100644 --- a/src/mcd-connection.c +++ b/src/mcd-connection.c @@ -477,7 +477,7 @@ _mcd_connection_setup_presence (McdConnection *connection) (priv->tp_conn, -1, self_handle_array, mcd_connection_initial_presence_cb, priv, NULL, (GObject *) connection); - g_array_free (self_handle_array, TRUE); + g_array_unref (self_handle_array); tp_cli_dbus_properties_call_get (priv->tp_conn, -1, TP_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE, @@ -638,7 +638,7 @@ _mcd_connection_setup_capabilities (McdConnection *connection) G_TYPE_UINT, G_TYPE_INVALID); for (i = 0; i < capabilities->len; i++) g_boxed_free (type, g_ptr_array_index (capabilities, i)); - g_ptr_array_free (capabilities, TRUE); + g_ptr_array_unref (capabilities); } static void @@ -849,7 +849,7 @@ avatars_request_tokens_cb (TpConnection *proxy, GHashTable *tokens, { DEBUG ("No avatar set, setting our own"); _mcd_connection_set_avatar (connection, avatar, mime_type); - g_array_free (avatar, TRUE); + g_array_unref (avatar); } g_free (mime_type); } @@ -900,7 +900,7 @@ _mcd_connection_setup_avatar (McdConnection *connection) priv, NULL, (GObject *)connection); } - g_array_free (avatar, TRUE); + g_array_unref (avatar); } g_free (mime_type); } @@ -972,7 +972,7 @@ _mcd_connection_set_nickname (McdConnection *connection, aliasing_set_aliases_cb, priv, NULL, (GObject *)connection); - g_hash_table_destroy (aliases); + g_hash_table_unref (aliases); } static void @@ -1028,7 +1028,7 @@ _mcd_connection_setup_alias (McdConnection *connection) tp_cli_connection_interface_aliasing_call_get_aliases (priv->tp_conn, -1, self_handle_array, _mcd_connection_get_aliases_cb, priv, NULL, (GObject *) connection); - g_array_free (self_handle_array, TRUE); + g_array_unref (self_handle_array); } static void @@ -1542,7 +1542,7 @@ list_channels_cb (TpConnection *connection, g_hash_table_insert (channel_props, TP_IFACE_CHANNEL ".TargetHandle", va->values + 3); mcd_connection_found_channel (self, object_path, channel_props); - g_hash_table_destroy (channel_props); + g_hash_table_unref (channel_props); } self->priv->dispatched_initial_channels = TRUE; @@ -1788,7 +1788,7 @@ mcd_connection_early_get_interfaces_cb (TpConnection *tp_conn, _mcd_connection_update_client_caps (self, client_caps); g_ptr_array_foreach (client_caps, (GFunc) g_value_array_free, NULL); - g_ptr_array_free (client_caps, TRUE); + g_ptr_array_unref (client_caps); } /* else the McdDispatcher hasn't sorted itself out yet, so * we can't usefully pre-load capabilities - we'll be told @@ -1950,7 +1950,7 @@ _mcd_connection_finalize (GObject * object) g_free (priv->alias); if (priv->recognized_presences) - g_hash_table_destroy (priv->recognized_presences); + g_hash_table_unref (priv->recognized_presences); G_OBJECT_CLASS (mcd_connection_parent_class)->finalize (object); } diff --git a/src/mcd-dbusprop.c b/src/mcd-dbusprop.c index d038d819..0e233608 100644 --- a/src/mcd-dbusprop.c +++ b/src/mcd-dbusprop.c @@ -331,7 +331,7 @@ get_all_iter (GetAllData *data) { tp_svc_dbus_properties_return_from_get_all (data->context, data->properties); - g_hash_table_destroy (data->properties); + g_hash_table_unref (data->properties); g_slice_free (GetAllData, data); } diff --git a/src/mcd-dispatch-operation.c b/src/mcd-dispatch-operation.c index f21edf80..95357434 100644 --- a/src/mcd-dispatch-operation.c +++ b/src/mcd-dispatch-operation.c @@ -2138,7 +2138,7 @@ _mcd_dispatch_operation_run_observers (McdDispatchOperation *self) g_list_free (observed); } - g_hash_table_destroy (observer_info); + g_hash_table_unref (observer_info); } static void diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c index 7ce02dd1..31b5b275 100644 --- a/src/mcd-dispatcher.c +++ b/src/mcd-dispatcher.c @@ -849,7 +849,7 @@ mcd_dispatcher_client_registry_ready_cb (McdClientRegistry *clients, } g_ptr_array_foreach (vas, (GFunc) g_value_array_free, NULL); - g_ptr_array_free (vas, TRUE); + g_ptr_array_unref (vas); } static void @@ -903,7 +903,7 @@ _mcd_dispatcher_dispose (GObject * object) tp_clear_object (&priv->clients); } - tp_clear_pointer (&priv->connections, g_hash_table_destroy); + tp_clear_pointer (&priv->connections, g_hash_table_unref); tp_clear_object (&priv->master); tp_clear_object (&priv->dbus_daemon); @@ -940,7 +940,7 @@ mcd_dispatcher_update_client_caps (McdDispatcher *self, } g_ptr_array_foreach (vas, (GFunc) g_value_array_free, NULL); - g_ptr_array_free (vas, TRUE); + g_ptr_array_unref (vas); } static void @@ -2126,7 +2126,7 @@ _mcd_dispatcher_add_connection (McdDispatcher *self, _mcd_connection_start_dispatching (connection, vas); g_ptr_array_foreach (vas, (GFunc) g_value_array_free, NULL); - g_ptr_array_free (vas, TRUE); + g_ptr_array_unref (vas); } /* else _mcd_connection_start_dispatching will be called when we're ready * for it */ diff --git a/src/mcd-handler-map.c b/src/mcd-handler-map.c index 63094b39..18d76d17 100644 --- a/src/mcd-handler-map.c +++ b/src/mcd-handler-map.c @@ -141,7 +141,7 @@ _mcd_handler_map_dispose (GObject *object) { McdHandlerMap *self = MCD_HANDLER_MAP (object); - tp_clear_pointer (&self->priv->handled_channels, g_hash_table_destroy); + tp_clear_pointer (&self->priv->handled_channels, g_hash_table_unref); if (self->priv->handler_processes != NULL) { @@ -160,7 +160,7 @@ _mcd_handler_map_dispose (GObject *object) } - tp_clear_pointer (&self->priv->handler_processes, g_hash_table_destroy); + tp_clear_pointer (&self->priv->handler_processes, g_hash_table_unref); tp_clear_object (&self->priv->dbus_daemon); G_OBJECT_CLASS (_mcd_handler_map_parent_class)->dispose (object); @@ -171,9 +171,9 @@ _mcd_handler_map_finalize (GObject *object) { McdHandlerMap *self = MCD_HANDLER_MAP (object); - tp_clear_pointer (&self->priv->channel_processes, g_hash_table_destroy); - tp_clear_pointer (&self->priv->channel_clients, g_hash_table_destroy); - tp_clear_pointer (&self->priv->channel_accounts, g_hash_table_destroy); + tp_clear_pointer (&self->priv->channel_processes, g_hash_table_unref); + tp_clear_pointer (&self->priv->channel_clients, g_hash_table_unref); + tp_clear_pointer (&self->priv->channel_accounts, g_hash_table_unref); G_OBJECT_CLASS (_mcd_handler_map_parent_class)->finalize (object); } diff --git a/src/mcd-master.c b/src/mcd-master.c index 06bb60ce..a88ed496 100644 --- a/src/mcd-master.c +++ b/src/mcd-master.c @@ -250,7 +250,7 @@ mcd_master_unload_mcd_plugins (McdMaster *master) module = g_ptr_array_index (priv->mcd_plugins, i); g_module_close (module); } - g_ptr_array_free (priv->mcd_plugins, TRUE); + g_ptr_array_unref (priv->mcd_plugins); priv->mcd_plugins = NULL; } @@ -405,7 +405,7 @@ _mcd_master_dispose (GObject * object) object); g_object_unref (plugin); } - g_ptr_array_free (priv->transport_plugins, TRUE); + g_ptr_array_unref (priv->transport_plugins); priv->transport_plugins = NULL; } diff --git a/src/mcd-provisioning-factory.c b/src/mcd-provisioning-factory.c index f1c836de..2c28d2b5 100644 --- a/src/mcd-provisioning-factory.c +++ b/src/mcd-provisioning-factory.c @@ -53,7 +53,7 @@ mcd_provisioning_factory_dispose (GObject *object) McdProvisioningFactoryPriv *priv = MCD_PROVISIONING_FACTORY_GET_PRIV (object); if (priv->provs) { - g_hash_table_destroy (priv->provs); + g_hash_table_unref (priv->provs); priv->provs = NULL; } G_OBJECT_CLASS (mcd_provisioning_factory_parent_class)->dispose (object); |