GNOME Bugzilla – Bug 710964
Add g_hash_table_get_key_array()
Last modified: 2013-10-27 16:29:56 UTC
After finding myself writing code to do this manually for the second time in as many days (and having lots of memories of times past), I think we could use this API.
Created attachment 258222 [details] [review] Add g_hash_table_get_key_array() Returns a %NULL-terminated array of the keys of a hashtable. In the case that the hash table has strings for keys, this is actually a gchar**.
Review of attachment 258222 [details] [review]: Looks good to me. ::: glib/ghash.c @@ +1660,3 @@ + * value of this function can be conveniently cast to (gchar **). + * + * Returns: a %NULL-terminated array containing each key from the table. transfer-full, or a comment on how to free it ::: glib/ghash.h @@ +122,3 @@ +GLIB_AVAILABLE_IN_2_40 +gpointer * g_hash_table_get_key_array (GHashTable *hash_table, + guint *length); I'd prefer get_keys_as_array(). Fits better with get_keys().
Created attachment 258226 [details] [review] Add g_hash_table_get_keys_as_array() Returns a %NULL-terminated array of the keys of a hashtable. In the case that the hash table has strings for keys, this is actually a gchar**.
Created attachment 258227 [details] [review] tests: test g_hash_table_get_keys_as_array()
Review of attachment 258226 [details] [review]: Great, thanks. ::: docs/reference/glib/glib-sections.txt @@ +2297,3 @@ g_hash_table_get_keys g_hash_table_get_values +g_hash_table_get_key_array Change this as well please
Review of attachment 258227 [details] [review]: Ok.
Attachment 258226 [details] pushed as 2880767 - Add g_hash_table_get_keys_as_array() Attachment 258227 [details] pushed as ba31037 - tests: test g_hash_table_get_keys_as_array()