Re: [gtk-list] Hash table problems, again



Robert_Gasch/PeopleSoft@peoplesoft.com wrote:
> 
> Hi,
> 
> I've already asked about this a while ago, but didn't get any
> reactions. I'm still stuck on this, so I'm trying again ...
> 
> I can't quite figure out why the attached progrem doesn't just
> store and retrieve the strings "0" - "19" like it should. Can
> anybodypoint out to me what I'm doing wrong? It seems that the
> hash table does not copy key values, so giving each item a new
> string seems only appropriate but I'm still missing something.


> gint TFWhashcmp (gconstpointer a, gconstpointer b)
> {
>         return (strcmp((char *)a,(char *)b));
> }

You wanted to use !strcmp, so that it returns TRUE if the two values
are equal.

You can actually store integers directly in a GHashTable, using
the GPOINTER_TO_INT() and related macros.
(See http://glade.pn.org/glibdocs for some documentation on GLib)

Damon




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