summaryrefslogtreecommitdiff
path: root/src/libdatastruct/genset_iter_withcancel.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libdatastruct/genset_iter_withcancel.c')
-rw-r--r--src/libdatastruct/genset_iter_withcancel.c18
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 ;
+}