diff --git a/src/util/hash_table.c b/src/util/hash_table.c index 5ae9c4a9e88..54bd50c3cd4 100644 --- a/src/util/hash_table.c +++ b/src/util/hash_table.c @@ -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. */ diff --git a/src/util/hash_table.h b/src/util/hash_table.h index bb9bb84a4d0..c3163d90e76 100644 --- a/src/util/hash_table.h +++ b/src/util/hash_table.h @@ -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);