The hsh_string_hash() tries to avoid recalculation of a
hash value by saving the address of the last used key
and the value of the last used hash value.
There is an error in the calculation of "the last used
adddress".
Let's say we call hsh_string_hash() with a string of
length L, starting at address A. Then the "last used
key address" (prev_pt) is set to A + L instead of A. (
!) When we call hsh_string_hash() the next time with
a different key that happens to start at A + L, the
hash value isn't calculated but the stored one is used.
I'm using parts of the dictzip code, including libmaa,
in a project, and this was the source of a mysterious,
hard to reproduce bug in which sometimes a key that did
exist in the hash table could not be found by looking
up the key.
IMHO the caching should be removed altogether: there is
no guarantee that if the address is the same, the
string (key) will be the same.
Similar caching is used in hsh_pointer_hash().
Best regards,
Geert Kloosterman
Logged In: YES
user_id=587312
Fixed in CVS, thanks for pointing out.