diff options
author | Thomas Haller <thaller@redhat.com> | 2017-11-15 15:33:32 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-11-16 11:49:51 +0100 |
commit | ecd106101bcdd9ac56aac8765bf828f7137cc7e3 (patch) | |
tree | 853208513f9fcae8e9c868f5b1b4027d10296eff /shared | |
parent | c3d98a3df6432f3d9d143dec6d328feec0873b4a (diff) | |
download | NetworkManager-ecd106101bcdd9ac56aac8765bf828f7137cc7e3.tar.gz |
shared: use siphash24() for nm_hash_ptr()
siphash24() mixes the bits much better then our naive xor.
Don't bypass siphash24(). We supposedly use it for the
better hashing properties, so use it also for pointers.
Diffstat (limited to 'shared')
-rw-r--r-- | shared/nm-utils/nm-hash-utils.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/shared/nm-utils/nm-hash-utils.c b/shared/nm-utils/nm-hash-utils.c index 0d0ba373a1..e4daf1a07c 100644 --- a/shared/nm-utils/nm-hash-utils.c +++ b/shared/nm-utils/nm-hash-utils.c @@ -143,16 +143,13 @@ nm_str_hash (gconstpointer str) guint nm_hash_ptr (gconstpointer ptr) { - guint h; - - h = ((const guint *) _get_hash_key ())[0]; - - if (sizeof (ptr) <= sizeof (guint)) - h = h ^ ((guint) ((uintptr_t) ptr)); - else - h = h ^ ((guint) (((guint64) (uintptr_t) ptr) >> 32)) ^ ((guint) ((uintptr_t) ptr)); + NMHashState h; - return h ?: 2907677551u; + if (!ptr) + return nm_hash_static (2907677551u); + nm_hash_init (&h, 2907677551u); + nm_hash_update (&h, &ptr, sizeof (ptr)); + return nm_hash_complete (&h); } guint |