Re: g_int_hash function

ISO C9X defines the intptr_t and uintptr_t types which would be
perfect for this case. they are defined to be the smallest integral type that is
large enough to hold an arbitrary pointer. they are quite useful for portability
and this type of thing where you need an arbitrary 'cookie' which might be an
int and might be a ptr and you want to express that portably...  IMHO
encouraging the use of GINT_TO_POINTER and vice versa will DECREASE portability
in the future as it would put constraints on the valid values of gint and
gpointer.... (BTW they are defined in <stdint.h>)

On Sun, Aug 15, 1999 at 04:47:36PM +0100, Damon Chaplin wrote:
> It seems that if you use g_int_hash() and g_int_equal() for a hash table
> you have to pass in pointers to integers as keys.
> I thought it would be using the integers themselves as the keys.
>   g_hash_table_insert (hashtable, GINT_TO_POINTER (37), value);

John Meacham
California Institute of Technology, Student.
Sun Microsystems, Solaris Kernel Group.    

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