mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 15:38:09 +02:00
util: add _mesa_set_create_u32_keys where keys are not pointers
the only limitation is that key=0 is not allowed Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6955>
This commit is contained in:
parent
7f2ea2a433
commit
10a7682413
2 changed files with 23 additions and 0 deletions
|
|
@ -148,6 +148,26 @@ _mesa_set_create(void *mem_ctx,
|
||||||
return ht;
|
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 *
|
struct set *
|
||||||
_mesa_set_clone(struct set *set, void *dst_mem_ctx)
|
_mesa_set_clone(struct set *set, void *dst_mem_ctx)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,9 @@ _mesa_set_create(void *mem_ctx,
|
||||||
uint32_t (*key_hash_function)(const void *key),
|
uint32_t (*key_hash_function)(const void *key),
|
||||||
bool (*key_equals_function)(const void *a,
|
bool (*key_equals_function)(const void *a,
|
||||||
const void *b));
|
const void *b));
|
||||||
|
struct set *
|
||||||
|
_mesa_set_create_u32_keys(void *mem_ctx);
|
||||||
|
|
||||||
struct set *
|
struct set *
|
||||||
_mesa_set_clone(struct set *set, void *dst_mem_ctx);
|
_mesa_set_clone(struct set *set, void *dst_mem_ctx);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue