[Mesa-dev] [PATCH] util: hashtable: make hashing prototypes match

Kenneth Graunke kenneth at whitecape.org
Fri Oct 27 17:17:03 UTC 2017


On Friday, October 27, 2017 9:43:45 AM PDT Lionel Landwerlin wrote:
> It seems nobody's using the string hashing function. If you try to
> pass it directly to the hashtable creation function, you'll get
> compiler warning for non matching prototypes. Let's make them match.
> 
> Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
> ---
>  src/util/hash_table.c | 3 ++-
>  src/util/hash_table.h | 2 +-
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/src/util/hash_table.c b/src/util/hash_table.c
> index 1bda2149b95..b7421a0144c 100644
> --- a/src/util/hash_table.c
> +++ b/src/util/hash_table.c
> @@ -476,9 +476,10 @@ _mesa_hash_data(const void *data, size_t size)
>  
>  /** FNV-1a string hash implementation */
>  uint32_t
> -_mesa_hash_string(const char *key)
> +_mesa_hash_string(const void *_key)
>  {
>     uint32_t hash = _mesa_fnv32_1a_offset_bias;
> +   const char *key = _key;
>  
>     while (*key != 0) {
>        hash = _mesa_fnv32_1a_accumulate(hash, *key);
> diff --git a/src/util/hash_table.h b/src/util/hash_table.h
> index cf939130fcf..d3e0758b265 100644
> --- a/src/util/hash_table.h
> +++ b/src/util/hash_table.h
> @@ -94,7 +94,7 @@ _mesa_hash_table_random_entry(struct hash_table *ht,
>                                bool (*predicate)(struct hash_entry *entry));
>  
>  uint32_t _mesa_hash_data(const void *data, size_t size);
> -uint32_t _mesa_hash_string(const char *key);
> +uint32_t _mesa_hash_string(const void *key);
>  bool _mesa_key_string_equal(const void *a, const void *b);
>  bool _mesa_key_pointer_equal(const void *a, const void *b);
>  
> 

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20171027/a3a8130a/attachment.sig>


More information about the mesa-dev mailing list