mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-26 19:20:08 +01:00
util: rzalloc and free hash_table_u64
Otherwise we're prone to leaking the table itself, since it's not freed
in the destroy function
CID: 1516552
fixes: 6649b840c3
("mesa/util: add a hash table wrapper which support 64-bit keys")
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21499>
This commit is contained in:
parent
75968398f3
commit
ff494361be
1 changed files with 4 additions and 7 deletions
|
|
@ -775,15 +775,15 @@ _mesa_hash_table_u64_create(void *mem_ctx)
|
|||
STATIC_ASSERT(FREED_KEY_VALUE != DELETED_KEY_VALUE);
|
||||
struct hash_table_u64 *ht;
|
||||
|
||||
ht = CALLOC_STRUCT(hash_table_u64);
|
||||
ht = rzalloc(mem_ctx, struct hash_table_u64);
|
||||
if (!ht)
|
||||
return NULL;
|
||||
|
||||
if (sizeof(void *) == 8) {
|
||||
ht->table = _mesa_hash_table_create(mem_ctx, _mesa_hash_pointer,
|
||||
ht->table = _mesa_hash_table_create(ht, _mesa_hash_pointer,
|
||||
_mesa_key_pointer_equal);
|
||||
} else {
|
||||
ht->table = _mesa_hash_table_create(mem_ctx, key_u64_hash,
|
||||
ht->table = _mesa_hash_table_create(ht, key_u64_hash,
|
||||
key_u64_equals);
|
||||
}
|
||||
|
||||
|
|
@ -821,10 +821,7 @@ _mesa_hash_table_u64_destroy(struct hash_table_u64 *ht)
|
|||
{
|
||||
if (!ht)
|
||||
return;
|
||||
|
||||
_mesa_hash_table_u64_clear(ht);
|
||||
_mesa_hash_table_destroy(ht->table, NULL);
|
||||
free(ht);
|
||||
ralloc_free(ht);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue