amdgpu/util_hash_table: Add helper function to count the number of entries in hash table

Analogous to the mesa commit of the same name.
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
main
Jan Vesely 2018-05-18 11:36:20 -04:00
parent 712fa0f3f4
commit 52ef6fbaf1
2 changed files with 14 additions and 0 deletions

View File

@ -237,6 +237,18 @@ drm_private void util_hash_table_foreach(struct util_hash_table *ht,
}
}
static void util_hash_table_inc(void *k, void *v, void *d)
{
++*(size_t *)d;
}
drm_private size_t util_hash_table_count(struct util_hash_table *ht)
{
size_t count = 0;
util_hash_table_foreach(ht, util_hash_table_inc, &count);
return count;
}
drm_private void util_hash_table_destroy(struct util_hash_table *ht)
{
struct util_hash_iter iter;

View File

@ -64,6 +64,8 @@ drm_private void util_hash_table_foreach(struct util_hash_table *ht,
void (*callback)(void *key, void *value, void *data),
void *data);
drm_private size_t util_hash_table_count(struct util_hash_table *ht);
drm_private void util_hash_table_destroy(struct util_hash_table *ht);
#endif /* U_HASH_TABLE_H_ */