GHashTable ( Missing something ?)
- From: Harring Figueiredo <harringf yahoo com>
- To: gtk-app-devel-list gnome org
- Subject: GHashTable ( Missing something ?)
- Date: Fri, 24 Sep 2004 11:45:53 -0700 (PDT)
Folks, I am doing a lookup on a hastable, and it always returns NULL, even
though the key exist -- (Now, I know it's is friday, but I have not started
drinking yet :P) -- Note that the GEqualFunc is never called.
---- <code> --------------------
gboolean my_str_compare(char* k, char* k2){
fprintf(stderr,"Comparing k=[%s] with k2=[%s]\n", k, k2);
//return g_str_equal((gpointer)k,(gpointer)k2);
return strcmp(k,k2) == 0;
}
void dump(gpointer pkey, gpointer entry, gpointer _null)
{
CfgEntry* e = (CfgEntry*) entry;
fprintf(stderr, "DUMP key(p)=%s, val=%s, d=%s\n", (char*)pkey, e->val,
e->desc);
fprintf(stderr, "DUMP key=%s, val=%s, d=%s\n", e->key, e->val, e->desc);
}
CfgEntry* cfg_get_entry(const char* key){
g_return_val_if_fail(key != NULL, NULL);
fprintf(stderr, "Looking for passed in key: %s\n", key);
g_hash_table_foreach(table, dump, NULL);
return g_hash_table_lookup(table, key);
}
My Hastable is created with:
g_hash_table_netable = g_hash_table_new_full(g_str_hash,
(GEqualFunc)my_str_compare, NULL, (GDestroyNotify)cfg_entry_unref );
--------------- </code> -----------------------
----------- <output> ---------------
Looking for passed in key: My_key
DUMP key(p)=MY_key, val=value for the key, d=#description for this entry
DUMP key=MY_key, val=value for the key, d=#description for this entry
Did not find entry for key
-------------- </output>----------------------
NOTE that the my_str_compare is never called.
What the heck am I missing here ?
Perhaps I need a break from the keyboard..
Thanks for any help.
Harring
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]