Extend the foreach implementation
This commit is contained in:
+2
-2
@@ -163,7 +163,7 @@ _Bool libcdsb_list_update(list_t* x, ssize_t i, const void* v, vtype t, int ins)
|
||||
/*#####################################################################################################################*/
|
||||
|
||||
|
||||
int libcdsb_list_foreach(const vtype_list* x, int (*callback)(void* value, ssize_t index, vtype type)) {
|
||||
int libcdsb_list_foreach(const vtype_list* x, void* data, int (*callback)(void* value, ssize_t index, vtype type, void* data)) {
|
||||
|
||||
lnode_t* c;
|
||||
size_t n;
|
||||
@@ -173,7 +173,7 @@ int libcdsb_list_foreach(const vtype_list* x, int (*callback)(void* value, ssize
|
||||
n = 0;
|
||||
|
||||
while (!is_null(c)) {
|
||||
if ((r = callback(vnode_peek(&c->node, c->type), n, c->type)) != 0)
|
||||
if ((r = callback(vnode_peek(&c->node, c->type), n, c->type, data)) != 0)
|
||||
return r;
|
||||
c = c->next;
|
||||
++n;
|
||||
|
||||
Reference in New Issue
Block a user