Re: GHashTable



Andreas Volz wrote:

Hi,

I've some questions about GHashTable. I used a GHashTable in the past to
store some char* key and value pairs without problems. Now I like to
store GladeXML* as value and a char* as key. This is what I tried:

static GHashTable *glade_hash;

void register_glade_parent (GladeXML *glade_xml, const char *parent_name)
{
 static gboolean init = FALSE;

 if (!init)
 {
   glade_hash = g_hash_table_new_full (g_direct_hash, g_direct_equal,
                                       g_free, g_free);
here's your problem. if i'm understanding correctly, your keys are still just char * strings. the hash function and equal function are applied to the key, so you want to use g_str_hash and g_str_equal here.

   -brian




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