diff options
author | Xavier Claessens <xclaesse@gmail.com> | 2011-11-16 15:55:42 +0100 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2011-11-16 15:55:42 +0100 |
commit | 97c206797c9bb0f1893f845c01f28c301b92200e (patch) | |
tree | 88a6e76dad01d187d5e08b6b46f00b782344bd02 | |
parent | c216947c02b161eb4ab11ec8ae1b2e9b99a703ed (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-- | tests/wocky-roster-test.c | 2 | ||||
-rw-r--r-- | tests/wocky-test-stream.c | 4 | ||||
-rw-r--r-- | wocky/wocky-bare-contact.c | 4 | ||||
-rw-r--r-- | wocky/wocky-c2s-porter.c | 4 | ||||
-rw-r--r-- | wocky/wocky-caps-hash.c | 12 | ||||
-rw-r--r-- | wocky/wocky-contact-factory.c | 6 | ||||
-rw-r--r-- | wocky/wocky-disco-identity.c | 2 | ||||
-rw-r--r-- | wocky/wocky-loopback-stream.c | 4 | ||||
-rw-r--r-- | wocky/wocky-meta-porter.c | 6 | ||||
-rw-r--r-- | wocky/wocky-pubsub-service.c | 2 | ||||
-rw-r--r-- | wocky/wocky-roster.c | 8 | ||||
-rw-r--r-- | wocky/wocky-sasl-digest-md5.c | 4 |
12 files changed, 29 insertions, 29 deletions
diff --git a/tests/wocky-roster-test.c b/tests/wocky-roster-test.c index 49a0efc..7ead218 100644 --- a/tests/wocky-roster-test.c +++ b/tests/wocky-roster-test.c @@ -630,7 +630,7 @@ check_edit_roster_stanza (WockyStanza *stanza, } g_assert (g_hash_table_size (expected_groups) == 0); - g_hash_table_destroy (expected_groups); + g_hash_table_unref (expected_groups); } static void diff --git a/tests/wocky-test-stream.c b/tests/wocky-test-stream.c index 80e4df7..8722b12 100644 --- a/tests/wocky-test-stream.c +++ b/tests/wocky-test-stream.c @@ -289,7 +289,7 @@ wocky_test_input_stream_read (GInputStream *stream, void *buffer, gsize count, if (self->offset == self->out_array->len) { - g_array_free (self->out_array, TRUE); + g_array_unref (self->out_array); self->out_array = g_async_queue_try_pop (self->queue); self->offset = 0; } @@ -435,7 +435,7 @@ wocky_test_input_stream_dispose (GObject *object) self->dispose_has_run = TRUE; if (self->out_array != NULL) - g_array_free (self->out_array, TRUE); + g_array_unref (self->out_array); self->out_array = NULL; if (self->queue != NULL) diff --git a/wocky/wocky-bare-contact.c b/wocky/wocky-bare-contact.c index aecce9a..11e7bd1 100644 --- a/wocky/wocky-bare-contact.c +++ b/wocky/wocky-bare-contact.c @@ -493,8 +493,8 @@ groups_equal (const gchar * const * groups_a, result = FALSE; } - g_ptr_array_free (arr_a, TRUE); - g_ptr_array_free (arr_b, TRUE); + g_ptr_array_unref (arr_a); + g_ptr_array_unref (arr_b); return result; } diff --git a/wocky/wocky-c2s-porter.c b/wocky/wocky-c2s-porter.c index 713df5a..e0e92f7 100644 --- a/wocky/wocky-c2s-porter.c +++ b/wocky/wocky-c2s-porter.c @@ -568,9 +568,9 @@ wocky_c2s_porter_finalize (GObject *object) g_assert_cmpuint (g_queue_get_length (priv->sending_queue), ==, 0); g_queue_free (priv->sending_queue); - g_hash_table_destroy (priv->handlers_by_id); + g_hash_table_unref (priv->handlers_by_id); g_list_free (priv->handlers); - g_hash_table_destroy (priv->iq_reply_handlers); + g_hash_table_unref (priv->iq_reply_handlers); g_queue_free (priv->unimportant_queue); diff --git a/wocky/wocky-caps-hash.c b/wocky/wocky-caps-hash.c index 976b375..a610075 100644 --- a/wocky/wocky-caps-hash.c +++ b/wocky/wocky-caps-hash.c @@ -266,11 +266,11 @@ wocky_caps_hash_compute_from_lists ( cleanup: g_checksum_free (checksum); - g_hash_table_destroy (form_names); + g_hash_table_unref (form_names); - g_ptr_array_free (identities_sorted, TRUE); - g_ptr_array_free (features_sorted, TRUE); - g_ptr_array_free (dataforms_sorted, TRUE); + g_ptr_array_unref (identities_sorted); + g_ptr_array_unref (features_sorted); + g_ptr_array_unref (dataforms_sorted); return encoded; } @@ -362,8 +362,8 @@ wocky_caps_hash_compute_from_node (WockyNode *node) out: wocky_disco_identity_array_free (identities); - g_ptr_array_free (features, TRUE); - g_ptr_array_free (dataforms, TRUE); + g_ptr_array_unref (features); + g_ptr_array_unref (dataforms); return str; } diff --git a/wocky/wocky-contact-factory.c b/wocky/wocky-contact-factory.c index fcf75d3..8f78b34 100644 --- a/wocky/wocky-contact-factory.c +++ b/wocky/wocky-contact-factory.c @@ -198,9 +198,9 @@ wocky_contact_factory_finalize (GObject *object) WockyContactFactory *self = WOCKY_CONTACT_FACTORY (object); WockyContactFactoryPrivate *priv = self->priv; - g_hash_table_destroy (priv->bare_contacts); - g_hash_table_destroy (priv->resource_contacts); - g_hash_table_destroy (priv->ll_contacts); + g_hash_table_unref (priv->bare_contacts); + g_hash_table_unref (priv->resource_contacts); + g_hash_table_unref (priv->ll_contacts); G_OBJECT_CLASS (wocky_contact_factory_parent_class)->finalize (object); } diff --git a/wocky/wocky-disco-identity.c b/wocky/wocky-disco-identity.c index e27c9e6..f356f3b 100644 --- a/wocky/wocky-disco-identity.c +++ b/wocky/wocky-disco-identity.c @@ -175,7 +175,7 @@ wocky_disco_identity_array_free (GPtrArray *arr) if (arr == NULL) return; - g_ptr_array_free (arr, TRUE); + g_ptr_array_unref (arr); } /** diff --git a/wocky/wocky-loopback-stream.c b/wocky/wocky-loopback-stream.c index 64bc6b2..702434a 100644 --- a/wocky/wocky-loopback-stream.c +++ b/wocky/wocky-loopback-stream.c @@ -241,7 +241,7 @@ wocky_loopback_input_stream_read (GInputStream *stream, if (self->offset == self->out_array->len) { - g_array_free (self->out_array, TRUE); + g_array_unref (self->out_array); self->out_array = g_async_queue_try_pop (self->queue); self->offset = 0; } @@ -382,7 +382,7 @@ wocky_loopback_input_stream_dispose (GObject *object) self->dispose_has_run = TRUE; if (self->out_array != NULL) - g_array_free (self->out_array, TRUE); + g_array_unref (self->out_array); self->out_array = NULL; if (self->queue != NULL) diff --git a/wocky/wocky-meta-porter.c b/wocky/wocky-meta-porter.c index dad0247..97691c5 100644 --- a/wocky/wocky-meta-porter.c +++ b/wocky/wocky-meta-porter.c @@ -605,7 +605,7 @@ free_handler (gpointer data) stanza_handler_porter_disposed_cb, handler); } - g_hash_table_destroy (handler->porters); + g_hash_table_unref (handler->porters); if (handler->contact != NULL) g_object_unref (handler->contact); g_object_unref (handler->stanza); @@ -738,8 +738,8 @@ wocky_meta_porter_dispose (GObject *object) g_socket_service_stop (priv->listener); g_object_unref (priv->listener); - g_hash_table_destroy (priv->porters); - g_hash_table_destroy (priv->handlers); + g_hash_table_unref (priv->porters); + g_hash_table_unref (priv->handlers); if (G_OBJECT_CLASS (wocky_meta_porter_parent_class)->dispose) G_OBJECT_CLASS (wocky_meta_porter_parent_class)->dispose (object); diff --git a/wocky/wocky-pubsub-service.c b/wocky/wocky-pubsub-service.c index bbda38b..869ae03 100644 --- a/wocky/wocky-pubsub-service.c +++ b/wocky/wocky-pubsub-service.c @@ -169,7 +169,7 @@ wocky_pubsub_service_dispose (GObject *object) g_slice_free (EventTrampoline, t); } - g_ptr_array_free (priv->trampolines, TRUE); + g_ptr_array_unref (priv->trampolines); priv->trampolines = NULL; g_object_unref (priv->porter); diff --git a/wocky/wocky-roster.c b/wocky/wocky-roster.c index 70c9165..4c0180e 100644 --- a/wocky/wocky-roster.c +++ b/wocky/wocky-roster.c @@ -114,8 +114,8 @@ pending_operation_free (PendingOperation *pending) g_slist_foreach (pending->waiting_operations, (GFunc) g_object_unref, NULL); g_slist_free (pending->waiting_operations); - g_hash_table_destroy (pending->groups_to_add); - g_hash_table_destroy (pending->groups_to_remove); + g_hash_table_unref (pending->groups_to_add); + g_hash_table_unref (pending->groups_to_remove); g_slice_free (PendingOperation, pending); } @@ -592,8 +592,8 @@ wocky_roster_finalize (GObject *object) WockyRoster *self = WOCKY_ROSTER (object); WockyRosterPrivate *priv = self->priv; - g_hash_table_destroy (priv->items); - g_hash_table_destroy (priv->pending_operations); + g_hash_table_unref (priv->items); + g_hash_table_unref (priv->pending_operations); G_OBJECT_CLASS (wocky_roster_parent_class)->finalize (object); } diff --git a/wocky/wocky-sasl-digest-md5.c b/wocky/wocky-sasl-digest-md5.c index b98257e..6ad7dd0 100644 --- a/wocky/wocky-sasl-digest-md5.c +++ b/wocky/wocky-sasl-digest-md5.c @@ -264,7 +264,7 @@ digest_md5_challenge_to_hash (const GString * challenge) error: DEBUG ("Failed to parse challenge: %s", challenge->str); - g_hash_table_destroy (result); + g_hash_table_unref (result); return NULL; } @@ -498,7 +498,7 @@ digest_md5_handle_auth_data (WockyAuthHandler *handler, WOCKY_AUTH_ERROR_INVALID_REPLY, "Server sent unexpected auth data"); } - g_hash_table_destroy (h); + g_hash_table_unref (h); return ret; } |