Re: GPOINTER_TO_UINT(NULL) == 0 ?



From: Jim Edwards <jimedwards altavista com>
>
> I think so
>
> glibconfig.h:
> #define GPOINTER_TO_UINT(p) ((guint)  (p))
> #define GPOINTER_TO_INT(p) ((gint)   (p))

The thing is, anything in glibconfig.h is _platform specific_.
On _your platform_, the macros are defined that way,
so GPOINTER_TO_UINT(NULL) is obviously zero. What I was asking
was if there were any platforms for which the macro had some weird
definition that broke this.

> but why would you need to make such an assumption?

I'm storing a ref count as the value in a hash table. Since
looking up a key in the hash table returns NULL if the key
isn't found, it's basically impossible to store a NULL
value. It makes life a lot simpler if that corresponds
to a ref count of 0, which I don't need to store.

> rsteinke w-link net wrote:
>
> >         Is it possible to assume that
> >
> > GPOINTER_TO_UINT(NULL) == 0
> >
> > across all platforms? Whether this is true or false, it
> > might also be a good thing to mention in the docs.

Ron Steinke



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