util/hash_table: _mesa_hash_table_create_u32_keys()
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10673>
This commit is contained in:
parent
e5fc2064fc
commit
c449a8a2c1
|
@ -191,6 +191,26 @@ _mesa_hash_table_create(void *mem_ctx,
|
|||
return ht;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
key_u32_hash(const void *key)
|
||||
{
|
||||
uint32_t u = (uint32_t)(uintptr_t)key;
|
||||
return _mesa_hash_uint(&u);
|
||||
}
|
||||
|
||||
static bool
|
||||
key_u32_equals(const void *a, const void *b)
|
||||
{
|
||||
return (uint32_t)(uintptr_t)a == (uint32_t)(uintptr_t)b;
|
||||
}
|
||||
|
||||
/* key == 0 and key == deleted_key are not allowed */
|
||||
struct hash_table *
|
||||
_mesa_hash_table_create_u32_keys(void *mem_ctx)
|
||||
{
|
||||
return _mesa_hash_table_create(mem_ctx, key_u32_hash, key_u32_equals);
|
||||
}
|
||||
|
||||
struct hash_table *
|
||||
_mesa_hash_table_clone(struct hash_table *src, void *dst_mem_ctx)
|
||||
{
|
||||
|
|
|
@ -72,6 +72,9 @@ _mesa_hash_table_init(struct hash_table *ht,
|
|||
bool (*key_equals_function)(const void *a,
|
||||
const void *b));
|
||||
|
||||
struct hash_table *
|
||||
_mesa_hash_table_create_u32_keys(void *mem_ctx);
|
||||
|
||||
struct hash_table *
|
||||
_mesa_hash_table_clone(struct hash_table *src, void *dst_mem_ctx);
|
||||
void _mesa_hash_table_destroy(struct hash_table *ht,
|
||||
|
|
Loading…
Reference in New Issue