[glib/glib-2-60: 4/6] ghash: Be more explicit about memory in g_hash_table_destroy_all_nodes()
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/glib-2-60: 4/6] ghash: Be more explicit about memory in g_hash_table_destroy_all_nodes()
- Date: Tue, 21 May 2019 10:30:11 +0000 (UTC)
commit 2b13c3f7974e3933dd12e39b07706188cff71a4e
Author: Allison Karlitskaya <allison karlitskaya redhat com>
Date: Mon May 20 16:39:35 2019 +0200
ghash: Be more explicit about memory in g_hash_table_destroy_all_nodes()
Make it clear that there is a reference transfer going on here, rather
than relying on the fields being overwritten on each branch of the
conditional below.
glib/ghash.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
---
diff --git a/glib/ghash.c b/glib/ghash.c
index bb04fdbc0..82c3365f6 100644
--- a/glib/ghash.c
+++ b/glib/ghash.c
@@ -635,9 +635,9 @@ g_hash_table_remove_all_nodes (GHashTable *hash_table,
* freeing them below.
*/
old_size = hash_table->size;
- old_keys = hash_table->keys;
- old_values = hash_table->values;
- old_hashes = hash_table->hashes;
+ old_keys = g_steal_pointer (&hash_table->keys);
+ old_values = g_steal_pointer (&hash_table->values);
+ old_hashes = g_steal_pointer (&hash_table->hashes);
if (!destruction)
/* Any accesses will see an empty table */
@@ -649,12 +649,7 @@ g_hash_table_remove_all_nodes (GHashTable *hash_table,
}
else
/* Will cause a quick crash on any attempted access */
- {
- hash_table->size = hash_table->mod = hash_table->mask = 0;
- hash_table->keys = NULL;
- hash_table->values = NULL;
- hash_table->hashes = NULL;
- }
+ hash_table->size = hash_table->mod = hash_table->mask = 0;
/* Now do the actual destroy notifies */
for (i = 0; i < old_size; i++)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]