summaryrefslogtreecommitdiffstats
path: root/src/idxset.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/idxset.c')
-rw-r--r--src/idxset.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/idxset.c b/src/idxset.c
index 4442190d..ea609f60 100644
--- a/src/idxset.c
+++ b/src/idxset.c
@@ -291,9 +291,7 @@ void* idxset_rrobin(struct idxset *s, uint32_t *index) {
if (!e)
return NULL;
- if (index)
- *index = e->index;
-
+ *index = e->index;
return e->data;
}
@@ -308,6 +306,22 @@ void* idxset_first(struct idxset *s, uint32_t *index) {
return s->iterate_list_head->data;
}
+void *idxset_next(struct idxset *s, uint32_t *index) {
+ struct idxset_entry **a, *e = NULL;
+ assert(s && index);
+
+ if ((a = array_index(s, *index)) && *a)
+ e = (*a)->iterate_next;
+
+ if (e) {
+ *index = e->index;
+ return e->data;
+ } else {
+ *index = IDXSET_INVALID;
+ return NULL;
+ }
+}
+
int idxset_foreach(struct idxset*s, int (*func)(void *p, uint32_t index, int *del, void*userdata), void *userdata) {
struct idxset_entry *e;
@@ -341,3 +355,4 @@ int idxset_isempty(struct idxset *s) {
assert(s);
return s->n_entries == 0;
}
+