Mercurial > libjeffpc
changeset 823:ccb955138113
nvl: add nvl_numitems to get the number of items in an nvlist
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Fri, 30 Oct 2020 17:58:24 -0400 |
parents | f8d9ccf26563 |
children | 562d1c61194e |
files | include/jeffpc/nvl.h mapfile-vers nvl.c |
diffstat | 3 files changed, 7 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/include/jeffpc/nvl.h Fri Oct 30 17:57:53 2020 -0400 +++ b/include/jeffpc/nvl.h Fri Oct 30 17:58:24 2020 -0400 @@ -122,6 +122,7 @@ } /* iteration */ +extern size_t nvl_numitems(struct nvlist *nvl); extern const struct nvpair *nvl_iter_start(struct nvlist *nvl); extern const struct nvpair *nvl_iter_next(struct nvlist *nvl, const struct nvpair *prev);
--- a/mapfile-vers Fri Oct 30 17:57:53 2020 -0400 +++ b/mapfile-vers Fri Oct 30 17:58:24 2020 -0400 @@ -172,6 +172,7 @@ nvl_lookup_str; nvl_lookup_val; nvl_merge; + nvl_numitems; nvl_set; nvl_set_array; nvl_set_array_copy;
--- a/nvl.c Fri Oct 30 17:57:53 2020 -0400 +++ b/nvl.c Fri Oct 30 17:58:24 2020 -0400 @@ -56,6 +56,11 @@ * nvlist iteration */ +size_t nvl_numitems(struct nvlist *nvl) +{ + return rb_numnodes(&nvl->val._set_nvl.values); +} + const struct nvpair *nvl_iter_start(struct nvlist *nvl) { return rb_first(&nvl->val._set_nvl.values);