Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2017-10-28 10:28:55 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-10-28 10:28:55 +0300
commitfdae9e1e03e1fabf9e88a81a9b9bbee23bc1f456 (patch)
tree1e2be1ce885281e226ae9d852dd49f5e2ed634db /source/blender/blenlib/intern/array_store.c
parent8ac69ff9dcfc6aba8b5de8d53658612c8411b43b (diff)
BLI_array_store: correct hashing single bytes
The single byte version of hash_data was casting from unsigned char instead of signed. This didn't cause any errors since the result of each aren't compared. Even so, better keep them matching.
Diffstat (limited to 'source/blender/blenlib/intern/array_store.c')
-rw-r--r--source/blender/blenlib/intern/array_store.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/source/blender/blenlib/intern/array_store.c b/source/blender/blenlib/intern/array_store.c
index d3a63aceb89..5b1715bbb3d 100644
--- a/source/blender/blenlib/intern/array_store.c
+++ b/source/blender/blenlib/intern/array_store.c
@@ -763,7 +763,7 @@ static void bchunk_list_fill_from_array(
BLI_INLINE uint hash_data_single(const uchar p)
{
- return (HASH_INIT << 5) + HASH_INIT + (unsigned int)p;
+ return ((HASH_INIT << 5) + HASH_INIT) + (unsigned int)(*((signed char *)&p));
}
/* hash bytes, from BLI_ghashutil_strhash_n */
@@ -773,7 +773,7 @@ static uint hash_data(const uchar *key, size_t n)
unsigned int h = HASH_INIT;
for (p = (const signed char *)key; n--; p++) {
- h = (h << 5) + h + (unsigned int)*p;
+ h = ((h << 5) + h) + (unsigned int)*p;
}
return h;