Skip to content

Instantly share code, notes, and snippets.

@bert
Created November 11, 2010 06:56
Show Gist options
  • Save bert/672129 to your computer and use it in GitHub Desktop.
Save bert/672129 to your computer and use it in GitHub Desktop.
Dump a hash table
int
hash_table_dump (GHashTable * hash_table)
{
GHashTableIter iter;
gpointer key;
gpointer value;
g_hash_table_iter_init (hash_table, &iter);
while (g_hash_table_iter_next (&iter, &key, &value))
{
g_print ("key: %s, value: %s", (const char *) key, (const char *) value);
}
return (EXIT_SUCCESS);
}
static void
hash_table_dump_pair
(
const char *key,
const char *value
)
{
g_print ("Key: %s Value: %s\n", key, value);
}
...
g_hash_table_foreach (hash_table, (GHFunc) hash_table_dump_pair, NULL);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment