On Wed, Oct 08, 2008 at 10:25:19AM -0400, Jason Stover wrote:
> I'm having some trouble getting a matching entry in my
> hash table. It looks like the problem is here:
>
> /* Locates an entry matching TARGET. Returns the index for the
> entry, if found, or the index of an empty entry that indicates
> where TARGET should go, otherwise. */
> static inline unsigned
> locate_matching_entry (struct hsh_table *h, const void *target)
> {
> unsigned i = h->hash (target, h->aux);
>
> assert (h->hash_ordered);
> for (;;)
> {
> void *entry;
> i &= h->size - 1;
> entry = h->entries[i];
> if (entry == NULL || !h->compare (entry, target, h->aux))
> return i;
> i--;
> }
> }
>
> In my code, h->compare (entry, target, h->aux) returns 1 when
> entry and target match. So I would think locate_matching_entry()
> should return i, but it doesn't because of the !h->compare (...).
> Should this line be:
>
> if (entry == NULL || h->compare (entry, target, h->aux))
John just clarified over IRC that the return value here is supposed to be
strcmp-ish: 0 for a match.
So disregard.
-Jason
_______________________________________________
pspp-dev mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/pspp-dev