external/libdrm
Revision | 52ef6fbaf1962dac2a8b75078c20d65da90cfe8d (tree) |
---|---|
Time | 2018-05-26 01:12:00 |
Author | Jan Vesely <jan.vesely@rutg...> |
Commiter | Jan Vesely |
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>
@@ -237,6 +237,18 @@ drm_private void util_hash_table_foreach(struct util_hash_table *ht, | ||
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
240 | +static void util_hash_table_inc(void *k, void *v, void *d) | |
241 | +{ | |
242 | + ++*(size_t *)d; | |
243 | +} | |
244 | + | |
245 | +drm_private size_t util_hash_table_count(struct util_hash_table *ht) | |
246 | +{ | |
247 | + size_t count = 0; | |
248 | + util_hash_table_foreach(ht, util_hash_table_inc, &count); | |
249 | + return count; | |
250 | +} | |
251 | + | |
240 | 252 | drm_private void util_hash_table_destroy(struct util_hash_table *ht) |
241 | 253 | { |
242 | 254 | struct util_hash_iter iter; |
@@ -64,6 +64,8 @@ drm_private void util_hash_table_foreach(struct util_hash_table *ht, | ||
64 | 64 | void (*callback)(void *key, void *value, void *data), |
65 | 65 | void *data); |
66 | 66 | |
67 | +drm_private size_t util_hash_table_count(struct util_hash_table *ht); | |
68 | + | |
67 | 69 | drm_private void util_hash_table_destroy(struct util_hash_table *ht); |
68 | 70 | |
69 | 71 | #endif /* U_HASH_TABLE_H_ */ |