diff options
author | Jan Vesely <[email protected]> | 2018-05-09 15:06:33 -0400 |
---|---|---|
committer | Juan A. Suarez Romero <[email protected]> | 2018-05-15 11:14:49 +0200 |
commit | d2632fc7658728dfa8b06db6c9aa54239d5bb544 (patch) | |
tree | 491d0b6fbbcd0cd74b58c6796352cacd6b2c59d1 /src/gallium/auxiliary | |
parent | 83e543e9faf041008aa68ac006c786fd84cbadf3 (diff) |
gallium/auxiliary: Add helper function to count the number of entries in hash table
CC: <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Signed-off-by: Jan Vesely <[email protected]>
(cherry picked from commit d146768d139f887105464f0db5600dd046452a8f)
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/util/u_hash_table.c | 17 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_hash_table.h | 5 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_hash_table.c b/src/gallium/auxiliary/util/u_hash_table.c index 9e2b6b7de8b..77fa477e33a 100644 --- a/src/gallium/auxiliary/util/u_hash_table.c +++ b/src/gallium/auxiliary/util/u_hash_table.c @@ -270,6 +270,23 @@ util_hash_table_foreach(struct util_hash_table *ht, } +static enum pipe_error +util_hash_inc(void *k, void *v, void *d) +{ + ++*(size_t *)d; + return PIPE_OK; +} + + +size_t +util_hash_table_count(struct util_hash_table *ht) +{ + size_t count = 0; + util_hash_table_foreach(ht, util_hash_inc, &count); + return count; +} + + void util_hash_table_destroy(struct util_hash_table *ht) { diff --git a/src/gallium/auxiliary/util/u_hash_table.h b/src/gallium/auxiliary/util/u_hash_table.h index 9431761341e..ac00db8a00b 100644 --- a/src/gallium/auxiliary/util/u_hash_table.h +++ b/src/gallium/auxiliary/util/u_hash_table.h @@ -85,6 +85,11 @@ util_hash_table_foreach(struct util_hash_table *ht, (void *key, void *value, void *data), void *data); + +size_t +util_hash_table_count(struct util_hash_table *ht); + + void util_hash_table_destroy(struct util_hash_table *ht); |