Re: GHashTable



David Necas (Yeti) wrote:
On Mon, Jun 07, 2004 at 01:44:14AM +1000, Russell Shaw wrote:

I get a segfault with:

 GHashTable *hash=g_hash_table_new(g_int_hash,g_int_equal);
 g_hash_table_insert(hash,1,"Hi");


That's correct, 1 is hardly a valid pointer (to int or
anything else).  You probably want g_direct_hash.

Yeti

Hi,
Rereading the api, it seems that a pointer to the (key) value
to be hashed is needed, instead of the value itself.

I'm trying to use an 8-digit integer as the key, but the key
only exists as a local variable in a function that returns.

I need something like:

  hash_table_insert(hash,89798053,"a string");




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