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

#include <stdint.h>
#include <errno.h>

#include <skalibs/gensetdyn.h>

int gensetdyn_iter_withcancel (gensetdyn *g, iter_func_ref f, iter_func_ref cancelf, void *stuff)
{
  uint32_t n = gensetdyn_iter_nocancel(g, gensetdyn_n(g), f, stuff) ;
  if (n < gensetdyn_n(g))
  {
    int e = errno ;
    gensetdyn_iter_nocancel(g, n, cancelf, stuff) ;
    errno = e ;
    return 0 ;
  }
  return 1 ;
}