Function

GLibHashTablenew_full

Declaration

GHashTable*
g_hash_table_new_full (
  GHashFunc hash_func,
  GEqualFunc key_equal_func,
  GDestroyNotify key_destroy_func,
  GDestroyNotify value_destroy_func
)

Description

Creates a new GHashTable like g_hash_table_new() with a reference count of 1 and allows to specify functions to free the memory allocated for the key and value that get called when removing the entry from the GHashTable.

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 using g_hash_table_unref().

Parameters

hash_func

Type: GHashFunc

A function to create a hash value from a key.

key_equal_func

Type: GEqualFunc

A function to check two keys for equality.

key_destroy_func

Type: GDestroyNotify

A function to free the memory allocated for the key used when removing the entry from the GHashTable, or NULL if you don’t want to supply such a function.

value_destroy_func

Type: GDestroyNotify

A function to free the memory allocated for the value used when removing the entry from the GHashTable, or NULL if you don’t want to supply such a function.

Return value

Type: GHashTable

A new GHashTable.

The data is owned by the called function.