diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2015-01-09 16:10:40 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2015-01-09 16:10:40 +0000 |
commit | b59ce39f9779cf4b1ad423783b6a532f94a8e880 (patch) | |
tree | 4db0c2cc5de6b4fe5d01fb5cc762b6a74ce32d34 /src/libdatastruct/genset_iter_withcancel.c | |
parent | 157ecd01d6cc4598ce4b0ec9bd477abbbf41d6c5 (diff) | |
download | skalibs-b59ce39f9779cf4b1ad423783b6a532f94a8e880.tar.xz |
Add cancellation to iterators over avltree(n) and genset(dyn)
Diffstat (limited to 'src/libdatastruct/genset_iter_withcancel.c')
-rw-r--r-- | src/libdatastruct/genset_iter_withcancel.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/libdatastruct/genset_iter_withcancel.c b/src/libdatastruct/genset_iter_withcancel.c new file mode 100644 index 0000000..fa8074b --- /dev/null +++ b/src/libdatastruct/genset_iter_withcancel.c @@ -0,0 +1,18 @@ +/* ISC license. */ + +#include <errno.h> +#include <skalibs/functypes.h> +#include <skalibs/genset.h> + +int genset_iter_withcancel (genset *g, iterfunc_t_ref f, iterfunc_t_ref cancelf, void *stuff) +{ + unsigned int n = genset_iter(g, f, stuff) ; + if (n < g->max) + { + int e = errno ; + genset_iter_nocancel(g, n, cancelf, stuff) ; + errno = e ; + return 0 ; + } + return 1 ; +} |