-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solving problems: key duplication, incorrect hashmap size change on e… #15
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable colliding_hash_val
is unused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for catching it. I've just removed colliding_hash_val with next commit (a8a5769)
Fixing reported issues in hashmap.c :
Adding simple tests.c file with two tests for covering/explaining reported issues.