Hi Pete,
hashmap_remove() might open a gap in a sequence of entries which share the same hash value. This might lead to the situation that a hashmap_put() creates a duplicate key rather than updating an existing key.
A remedy would be to insert the "in_use=0" gap at the end of a sequence of entries with the same hash.
Hi Pete, hashmap_remove() might open a gap in a sequence of entries which share the same hash value. This might lead to the situation that a hashmap_put() creates a duplicate key rather than updating an existing key. A remedy would be to insert the "in_use=0" gap at the end of a sequence of entries with the same hash.
Example:
before hashmap_remove()
entry A; hash H; in_use=1 entry B; hash H; in_use=1 entry C; hash H; in_use=1
after hashmap_remove(map, "B")
entry A; hash H; in_use=1 entry -; hash -; in_use=0 entry C; hash H; in_use=1
after hashmap_put(map, "C")
entry A; hash H; in_use=1 entry C; hash H; in_use=1 entry C; hash H; in_use=1
I could write a fixed version, but I am not yet familiar enough with github to deal with pull requests.
Greetings
Axel Kemper