summaryrefslogtreecommitdiff
path: root/src/libdatastruct/genset_iter_withcancel.c
blob: fa8074bad47a4aa48c6e0bdc9de757df9b65ce49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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 ;
}