In the doc for g_hash_table_new_full:
Since version 2.42 it is permissible for destroy notify functions to recursively remove further items from the hash table. This is only permissible if the application still holds a reference to the hash table. This means that you may need to ensure that the hash table is empty by calling
g_hash_table_remove_all()
before releasing the last reference usingg_hash_table_unref()
.
When the reference count drops to 0, all keys and values in the hash table will be freed using the provided GDestroyNotify
function anyway, so why do I still need to call g_hash_table_remove_all()
before g_hash_table_unref()
?