commit: a5dc7cb75f0dc1edd85ee26ce9d1a6636d4b40c0
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 27 14:56:12 2019 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Dec 27 14:56:12 2019 +0000
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a5dc7cb7
libq/set: add array_set function
like list_set, array_set returns all keys, but in an libq/xarray instead
of C-array.
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
libq/set.c | 16 ++++++++++++++++
libq/set.h | 1 +
2 files changed, 17 insertions(+)
diff --git a/libq/set.c b/libq/set.c
index 28c41a1..4529c3a 100644
--- a/libq/set.c
+++ b/libq/set.c
@@ -262,6 +262,22 @@ list_set(set *q, char ***l)
return q->len;
}
+size_t
+array_set(set *q, array_t *ret)
+{
+ int i;
+ set_elem *w;
+ array_t blank = array_init_decl;
+
+ *ret = blank;
+ for (i = 0; i < _SET_HASH_SIZE; i++) {
+ for (w = q->buckets[i]; w != NULL; w = w->next)
+ xarraypush_ptr(ret, w->name);
+ }
+
+ return q->len;
+}
+
size_t
values_set(set *q, array_t *ret)
{
diff --git a/libq/set.h b/libq/set.h
index 118d20d..c65eb0f 100644
--- a/libq/set.h
+++ b/libq/set.h
@@ -36,6 +36,7 @@ bool contains_set(const char *name, set *q);
void *get_set(const char *name, set *q);
void *del_set(const char *s, set *q, bool *removed);
size_t list_set(set *q, char ***l);
+size_t array_set(set *q, array_t *ret);
size_t values_set(set *q, array_t *ret);
size_t cnt_set(set *q);
void free_set(set *q);