mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 07:56:14 +01:00
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.
This commit is contained in:
parent
b3fbf6c18b
commit
9add93e5a4
13
glib/ghash.c
13
glib/ghash.c
@ -637,9 +637,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 */
|
||||
@ -651,12 +651,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++)
|
||||
|
Loading…
Reference in New Issue
Block a user