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.
This commit is contained in:
parent
8ac69ff9dc
commit
fdae9e1e03
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue