aboutsummaryrefslogtreecommitdiffstats
path: root/amdgpu/util_hash_table.c
diff options
context:
space:
mode:
authorJan Vesely <jan.vesely@rutgers.edu>2018-05-18 11:36:20 -0400
committerJan Vesely <jan.vesely@rutgers.edu>2018-05-25 12:12:00 -0400
commit52ef6fbaf1962dac2a8b75078c20d65da90cfe8d (patch)
tree4b139d73efaecea711d655f3554b4c9558238b92 /amdgpu/util_hash_table.c
parent712fa0f3f420a7b9b42ae6d6fcb513aca97d541d (diff)
downloadexternal_libdrm-52ef6fbaf1962dac2a8b75078c20d65da90cfe8d.tar.gz
external_libdrm-52ef6fbaf1962dac2a8b75078c20d65da90cfe8d.tar.bz2
external_libdrm-52ef6fbaf1962dac2a8b75078c20d65da90cfe8d.zip
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>
Diffstat (limited to 'amdgpu/util_hash_table.c')
-rw-r--r--amdgpu/util_hash_table.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/amdgpu/util_hash_table.c b/amdgpu/util_hash_table.c
index 89a8bf9b..e06d4415 100644
--- a/amdgpu/util_hash_table.c
+++ b/amdgpu/util_hash_table.c
@@ -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;