Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage-utils:master commit in: libq/
Date: Fri, 27 Dec 2019 16:57:10
Message-Id: 1577458572.a5dc7cb75f0dc1edd85ee26ce9d1a6636d4b40c0.grobian@gentoo
1 commit: a5dc7cb75f0dc1edd85ee26ce9d1a6636d4b40c0
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Fri Dec 27 14:56:12 2019 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Fri Dec 27 14:56:12 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a5dc7cb7
7
8 libq/set: add array_set function
9
10 like list_set, array_set returns all keys, but in an libq/xarray instead
11 of C-array.
12
13 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
14
15 libq/set.c | 16 ++++++++++++++++
16 libq/set.h | 1 +
17 2 files changed, 17 insertions(+)
18
19 diff --git a/libq/set.c b/libq/set.c
20 index 28c41a1..4529c3a 100644
21 --- a/libq/set.c
22 +++ b/libq/set.c
23 @@ -262,6 +262,22 @@ list_set(set *q, char ***l)
24 return q->len;
25 }
26
27 +size_t
28 +array_set(set *q, array_t *ret)
29 +{
30 + int i;
31 + set_elem *w;
32 + array_t blank = array_init_decl;
33 +
34 + *ret = blank;
35 + for (i = 0; i < _SET_HASH_SIZE; i++) {
36 + for (w = q->buckets[i]; w != NULL; w = w->next)
37 + xarraypush_ptr(ret, w->name);
38 + }
39 +
40 + return q->len;
41 +}
42 +
43 size_t
44 values_set(set *q, array_t *ret)
45 {
46
47 diff --git a/libq/set.h b/libq/set.h
48 index 118d20d..c65eb0f 100644
49 --- a/libq/set.h
50 +++ b/libq/set.h
51 @@ -36,6 +36,7 @@ bool contains_set(const char *name, set *q);
52 void *get_set(const char *name, set *q);
53 void *del_set(const char *s, set *q, bool *removed);
54 size_t list_set(set *q, char ***l);
55 +size_t array_set(set *q, array_t *ret);
56 size_t values_set(set *q, array_t *ret);
57 size_t cnt_set(set *q);
58 void free_set(set *q);