diff --git a/src/util/set.c b/src/util/set.c index a9012b4e6d4..006d5d2a502 100644 --- a/src/util/set.c +++ b/src/util/set.c @@ -148,6 +148,26 @@ _mesa_set_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 set * +_mesa_set_create_u32_keys(void *mem_ctx) +{ + return _mesa_set_create(NULL, key_u32_hash, key_u32_equals); +} + struct set * _mesa_set_clone(struct set *set, void *dst_mem_ctx) { diff --git a/src/util/set.h b/src/util/set.h index 2e0a2d66f85..1836864213f 100644 --- a/src/util/set.h +++ b/src/util/set.h @@ -60,6 +60,9 @@ _mesa_set_create(void *mem_ctx, uint32_t (*key_hash_function)(const void *key), bool (*key_equals_function)(const void *a, const void *b)); +struct set * +_mesa_set_create_u32_keys(void *mem_ctx); + struct set * _mesa_set_clone(struct set *set, void *dst_mem_ctx);