Commit: 76b9eaf7a84ee2098c1ca1bf5cd4042c55ae76d7
Author: Campbell Barton
Date:   Sun Nov 4 16:44:28 2018 +1100
Branches: master
https://developer.blender.org/rB76b9eaf7a84ee2098c1ca1bf5cd4042c55ae76d7

Fix ghash masking out upper bits on 64bit systems

The code this was taken from assumes a 'size_t' result,
which isn't the case here.

In practice the bucket distribution wasn't bad,
even so this was a nop so best fix.

===================================================================

M       source/blender/blenlib/intern/BLI_ghash_utils.c

===================================================================

diff --git a/source/blender/blenlib/intern/BLI_ghash_utils.c 
b/source/blender/blenlib/intern/BLI_ghash_utils.c
index 953ceb3442b..a0d9fefe465 100644
--- a/source/blender/blenlib/intern/BLI_ghash_utils.c
+++ b/source/blender/blenlib/intern/BLI_ghash_utils.c
@@ -54,14 +54,16 @@ uint BLI_ghashutil_ptrhash(const void *key)
        return (uint)(intptr_t)key;
 }
 #else
-/* based python3.3's pointer hashing function */
+/* Based Python3.7's pointer hashing function. */
 uint BLI_ghashutil_ptrhash(const void *key)
 {
        size_t y = (size_t)key;
        /* bottom 3 or 4 bits are likely to be 0; rotate y by 4 to avoid
         * excessive hash collisions for dicts and sets */
-       y = (y >> 4) | (y << (8 * sizeof(void *) - 4));
-       return (uint)y;
+
+       /* Note: Unlike Python 'sizeof(uint)' is used instead of 'sizeof(void 
*)',
+        * Otherwise casting to 'uint' ignores the upper bits on 64bit 
platforms. */
+       return (uint)(y >> 4) | ((uint)y << (8 * sizeof(uint) - 4));
 }
 #endif
 bool BLI_ghashutil_ptrcmp(const void *a, const void *b)

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to