summaryrefslogtreecommitdiff
path: root/src/libdatastruct/avlnode_iter_withcancel.c
blob: a9e7802715932a04013e0ce9497004b212a613ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* ISC license. */

#include <errno.h>
#include <skalibs/avlnode.h>

int avlnode_iter_withcancel (avlnode *tree, uint32_t max, uint32_t root, avliter_func_ref f, avliter_func_ref cancelf, void *stuff)
{
  uint32_t 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 ;
}