Re: [gtk-list] Are GHashTable's deterministic?




On Fri, 24 Sep 1999, Stéphane Popinet wrote:
> 
> I'm using GHashTable's and I came accross a "curious" behavior. Changing
> the code size of my program (i.e. adding some functions) changed the
> behavior of the program (the new functions never being called). The
> first reaction is obviously to look for stack corruption and related
> symptoms. After a few hours (days?) of careful debuging, purifying and
> such, I realized that the difference in behavior was actually caused by
> a call to g_hash_table_foreach. What happened was that when the code
> size changed, the order in which items were stored in the GHashTable
> changed and g_hash_table_foreach did not step through items in the same
> order thus generating a different behavior.
> 

If you hash with the same keys you should get the same order each time,
though you can't rely on that order.

Maybe your hash keys are pointers or some other value that is not the same
each time.

Havoc




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