Function

GLibHashTableget_keys_as_array

since: 2.40

Declaration

gpointer*
g_hash_table_get_keys_as_array (
  GHashTable* hash_table,
  guint* length
)

Description

Retrieves every key inside hash_table, as an array.

The returned array is NULL-terminated but may contain NULL as a key. Use length to determine the true length if it’s possible that NULL was used as the value for a key.

Note: in the common case of a string-keyed GHashTable, the return value of this function can be conveniently cast to (const gchar **).

This iterates over every entry in the hash table to build its return value. To iterate over the entries in a GHashTable more efficiently, use a GHashTableIter.

You should always free the return result with g_free(). In the above-mentioned case of a string-keyed hash table, it may be appropriate to use g_strfreev() if you call g_hash_table_steal_all() first to transfer ownership of the keys.

Available since: 2.40

This function is not directly available to language bindings.

Parameters

hash_table

Type: GHashTable

A GHashTable.

The data is owned by the caller of the function.
length

Type: guint*

The length of the returned array.

The argument will be set by the function.
The argument can be NULL.

Return value

Type: An array of gpointer

A NULL-terminated array containing each key from the table.

The length of the array is in the length argument.
The caller of the function takes ownership of the data container, but not the data inside it.