mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-03-11 20:00:38 +01:00
util: make UINT32_MAX a reserved key for _mesa_hash_table_create_u32_keys
Having deleted_key be a reserved key probably wasn't useful, because it's not a constant: it's (uintptr_t)&deleted_key_value. Signed-off-by: Rhys Perry <pendingchaos02@gmail.com> Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40196>
This commit is contained in:
parent
e5c44017d4
commit
1fd1997ac3
2 changed files with 6 additions and 3 deletions
|
|
@ -250,18 +250,19 @@ 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 */
|
||||
/* It's preferred to use _mesa_hash_table_init_u32_keys instead of this to skip ralloc. */
|
||||
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 *ht = _mesa_hash_table_create(mem_ctx, key_u32_hash, key_u32_equals);
|
||||
_mesa_hash_table_set_deleted_key(ht, (void *)(uintptr_t)UINT32_MAX);
|
||||
return ht;
|
||||
}
|
||||
|
||||
void
|
||||
_mesa_hash_table_init_u32_keys(struct hash_table *ht, void *mem_ctx)
|
||||
{
|
||||
_mesa_hash_table_init(ht, mem_ctx, key_u32_hash, key_u32_equals);
|
||||
_mesa_hash_table_set_deleted_key(ht, (void *)(uintptr_t)UINT32_MAX);
|
||||
}
|
||||
|
||||
/* Copy the hash table from src to dst. */
|
||||
|
|
|
|||
|
|
@ -86,6 +86,8 @@ void
|
|||
_mesa_hash_table_fini(struct hash_table *ht,
|
||||
void (*delete_function)(struct hash_entry *entry));
|
||||
|
||||
/* key == 0 and key == UINT32_MAX are not allowed */
|
||||
/* It's preferred to use _mesa_hash_table_init_u32_keys instead of this to skip ralloc. */
|
||||
struct hash_table *
|
||||
_mesa_hash_table_create_u32_keys(void *mem_ctx);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue