Commit 52ef6fba authored by Jan Vesely's avatar Jan Vesely
Browse files

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's avatarJan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Michel Dänzer's avatarMichel Dänzer <michel.daenzer@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 712fa0f3
......@@ -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;
......
......@@ -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_ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment