g_hash_table_find()



Hi,
What does g_hash_table_find() return?
It returns a gpointer, but the api is unclear
on what it is.

Returns: The value of the first key/value pair is returned, for which func
         evaluates to TRUE. If no pair with the requested property is found,
         NULL is returned.

How can it point to a key *and* its value? I'm trying to get the key
value with little success (it's stored as a guint).

I'm using g_direct_hash().


static gboolean
findfunc(gpointer key, gpointer value, gpointer user_data)
{
    return !strcmp(value,user_data);  // value is a gchar*
}

gchar *s="groundzero";
gpointer key=g_hash_table_find(hashtab,findfunc,s);
guint n=GPOINTER_TO_UINT(key);
fprintf(stream,"%u",n);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]