Solving problems: key duplication, incorrect hashmap size change on e…#15
Solving problems: key duplication, incorrect hashmap size change on e…#15kostalski wants to merge 3 commits intopetewarden:masterfrom
Conversation
|
Hi, |
| /* has beed updated and keys are not collidinig any more. */ | ||
| /* Provided keys colliding_key1, colliding_key2 have to be updated, */ | ||
| /* so they collide again. */ | ||
| assert(hashmap_hash_int(hmap, colliding_key2) == colliding_keys_hash); |
There was a problem hiding this comment.
Why do I need different colliding keys for different architectures?
If I run this test on an iPhone Simulator it works, if I run it in an Android Simulator it doesn't ("717" works in Android Simulator)?
There was a problem hiding this comment.
Hi Andreas,
It's problem of big-endianess and some settings for Android NDK.
Functions:
- unsigned long crc32() line: 149, file: hashmap.c
- unsigned int hashmap_hash_int() line: 167, file: hashmap.c
are designed for calculating hash for strings and assume, they are working on lilte-endian platform. They will return different results for big-endian platforms and rather not correct ;)
Android supports little and big endianess. Try to setup to little-endian - it should solve the problem (more info: https://stackoverflow.com/questions/6212951/endianness-of-android-ndk).
hashmap.c
Outdated
| /* After removing element from hash map there can be need to move back */ | ||
| /* previously pushed elements - pushed moved forward because key colision. */ | ||
| void _hashmap_shift_chain_after_remove(hashmap_map *m, char *key, int pos){ | ||
| unsigned int colliding_hash_val; |
There was a problem hiding this comment.
The variable colliding_hash_val is unused.
There was a problem hiding this comment.
Thank you for catching it. I've just removed colliding_hash_val with next commit (a8a5769)
Update README to include deprecation
Fixing reported issues in hashmap.c :
Adding simple tests.c file with two tests for covering/explaining reported issues.