CC: <mesa-sta...@lists.freedesktop.org> Signed-off-by: Jan Vesely <jan.ves...@rutgers.edu> --- src/gallium/auxiliary/util/u_hash_table.c | 17 +++++++++++++++++ src/gallium/auxiliary/util/u_hash_table.h | 5 +++++ 2 files changed, 22 insertions(+)
diff --git a/src/gallium/auxiliary/util/u_hash_table.c b/src/gallium/auxiliary/util/u_hash_table.c index 9e2b6b7de8..77fa477e33 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 9431761341..ac00db8a00 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); -- 2.17.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev