diff options
author | Philip Withnall <philip@tecnocode.co.uk> | 2022-10-24 20:22:15 +0000 |
---|---|---|
committer | Philip Withnall <philip@tecnocode.co.uk> | 2022-10-24 20:22:15 +0000 |
commit | e33f23a6b59e1886e6456dded7e5b74945c7d34e (patch) | |
tree | 316969283f7946bb4d19ff4901e0a3588ef54368 | |
parent | 7b09713963244caf08bc660c848473a6606553c0 (diff) | |
parent | de7abf54c7a602dc1f7905a9d5baffe59f58a607 (diff) | |
download | glib-e33f23a6b59e1886e6456dded7e5b74945c7d34e.tar.gz |
Merge branch 'wip/smcv/64-bit-hash' into 'main'
ghash: Correctly retrieve low 32 bits of 64-bit values
Closes #2787
See merge request GNOME/glib!2994
-rw-r--r-- | glib/ghash.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/glib/ghash.c b/glib/ghash.c index 366c751ac..158779911 100644 --- a/glib/ghash.c +++ b/glib/ghash.c @@ -2496,7 +2496,9 @@ g_int64_equal (gconstpointer v1, guint g_int64_hash (gconstpointer v) { - return (guint) ((const guint) (*(guint64 *) v >> 32)) ^ (*(const guint *) v); + const guint64 *bits = v; + + return (guint) ((*bits >> 32) ^ (*bits & 0xffffffffU)); } /** @@ -2537,5 +2539,8 @@ g_double_equal (gconstpointer v1, guint g_double_hash (gconstpointer v) { - return (guint) ((const guint) (*(guint64 *) v >> 32)) ^ (*(const guint *) v); + /* Same as g_int64_hash() */ + const guint64 *bits = v; + + return (guint) ((*bits >> 32) ^ (*bits & 0xffffffffU)); } |