[vlc-devel] [PATCH 2/2] vlc_arrays.h: Dictionary: Use the correct type to store hash

Steve Lhomme robux4 at ycbcr.xyz
Fri Dec 4 11:06:23 CET 2020


On 2020-12-04 10:40, Francois Cartegnie wrote:
> Le 04/12/2020 à 10:31, Hugo Beauzée-Luyssen a écrit :
>> ---
>>   include/vlc_arrays.h | 8 ++++----
>>   1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/include/vlc_arrays.h b/include/vlc_arrays.h
>> index a7469359bb..44d9e5de6d 100644
>> --- a/include/vlc_arrays.h
>> +++ b/include/vlc_arrays.h
>> @@ -456,7 +456,7 @@ vlc_dictionary_has_key( const vlc_dictionary_t * 
>> p_dict, const char * psz_key )
>>       if( !p_dict->p_entries )
>>           return 0;
>> -    int i_pos = DictHash( psz_key, p_dict->i_size );
>> +    size_t i_pos = DictHash( psz_key, p_dict->i_size );
> 
> 
> Due to the shifts I don't think the result will be the same when size_t 
> < uint64_t
> 
>              i_hash += *psz_string++;
>              i_hash += i_hash << 10;
>              i_hash ^= i_hash >> 8;

The result doesn't have to be the same, it's an internal hash not saved 
and only used to get a position in a table. It's modulo to the size of 
the table so will most likely never even return a value higher than 8 or 
16 bits long.


More information about the vlc-devel mailing list