summaryrefslogtreecommitdiff
path: root/src/libdatastruct/avlnode_iter_withcancel.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libdatastruct/avlnode_iter_withcancel.c')
-rw-r--r--src/libdatastruct/avlnode_iter_withcancel.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libdatastruct/avlnode_iter_withcancel.c b/src/libdatastruct/avlnode_iter_withcancel.c
new file mode 100644
index 0000000..44ba12e
--- /dev/null
+++ b/src/libdatastruct/avlnode_iter_withcancel.c
@@ -0,0 +1,17 @@
+/* ISC license. */
+
+#include <errno.h>
+#include <skalibs/avlnode.h>
+
+int avlnode_iter_withcancel (avlnode *tree, unsigned int max, unsigned int root, avliterfunc_t_ref f, avliterfunc_t_ref cancelf, void *stuff)
+{
+ unsigned int cut = avlnode_iter_nocancel(tree, max, max, root, f, stuff) ;
+ if (cut != max)
+ {
+ int e = errno ;
+ avlnode_iter_nocancel(tree, max, cut, root, cancelf, stuff) ;
+ errno = e ;
+ return 0 ;
+ }
+ return 1 ;
+}