From ec9b6b5cfaa02ca75cd72c4472fa5530816cbe81 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 29 Feb 2024 20:40:27 -0400 Subject: [PATCH] util: add _mesa_hash_table_u64_num_entries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Alyssa Rosenzweig Reviewed-by: Marek Olšák Part-of: --- src/util/hash_table.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/util/hash_table.h b/src/util/hash_table.h index 2091ad01580..9bb9eb4de8c 100644 --- a/src/util/hash_table.h +++ b/src/util/hash_table.h @@ -200,6 +200,13 @@ struct hash_entry_u64 _mesa_hash_table_u64_next_entry(struct hash_table_u64 *ht, struct hash_entry_u64 *ent); +static inline uint32_t +_mesa_hash_table_u64_num_entries(struct hash_table_u64 *ht) +{ + return (!!ht->freed_key_data) + (!!ht->deleted_key_data) + + _mesa_hash_table_num_entries(ht->table); +} + /** * This foreach function is safe against deletion (which just replaces * an entry's data with the deleted marker), but not against insertion