[PATCH libdrm 2/3] amdgpu/util_hash_table: Add helper function to count the number of entries in hash table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Analogous to the mesa commit of the same name.
Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---
 amdgpu/util_hash_table.c | 12 ++++++++++++
 amdgpu/util_hash_table.h |  2 ++
 2 files changed, 14 insertions(+)

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;
diff --git a/amdgpu/util_hash_table.h b/amdgpu/util_hash_table.h
index 5e295a81..3ab81a12 100644
--- a/amdgpu/util_hash_table.h
+++ b/amdgpu/util_hash_table.h
@@ -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_ */
-- 
2.17.0



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux