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:
committed by
Marge Bot
parent
3b5114a34b
commit
1d0f44739d
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user