util/hash_table: Add _mesa_hash_table_u64_replace()

This function updates the data of a u64 hash_table entry and is safe to
use inside a hash_table_u64_foreach() loop.

Fixes: 7bea6f86 ("panvk: Overhaul the Bifrost descriptor set implementation")

Signed-off-by: Rebecca Mckeever <rebecca.mckeever@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32563>
This commit is contained in:
Rebecca Mckeever
2025-01-29 20:33:26 -08:00
committed by Marge Bot
parent 3b5114a34b
commit 1d0f44739d
2 changed files with 23 additions and 0 deletions
+18
View File
@@ -1006,3 +1006,21 @@ _mesa_hash_table_u64_next_entry(struct hash_table_u64 *ht,
._entry = next,
};
}
/* Updates the data of a u64 hash_table entry inside a
* hash_table_u64_foreach() loop
*/
void
_mesa_hash_table_u64_replace(struct hash_table_u64 *ht,
const struct hash_entry_u64 *ent,
void *new_data)
{
if (ent->_entry) {
ent->_entry->data = new_data;
} else if (ent->key == FREED_KEY_VALUE) {
ht->freed_key_data = new_data;
} else {
assert(ent->key == DELETED_KEY_VALUE);
ht->deleted_key_data = new_data;
}
}
+5
View File
@@ -220,6 +220,11 @@ _mesa_hash_table_u64_search(struct hash_table_u64 *ht, uint64_t key);
void
_mesa_hash_table_u64_remove(struct hash_table_u64 *ht, uint64_t key);
void
_mesa_hash_table_u64_replace(struct hash_table_u64 *ht,
const struct hash_entry_u64 *he,
void *new_data);
void
_mesa_hash_table_u64_clear(struct hash_table_u64 *ht);