summaryrefslogtreecommitdiff
path: root/src/libdatastruct/gensetdyn_iter_withcancel.c
blob: c524b1cb4e7b4b8ce1fa6e71361904cec6366627 (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/gensetdyn.h>

int gensetdyn_iter_withcancel (gensetdyn *g, iterfunc_t_ref f, iterfunc_t_ref cancelf, void *stuff)
{
  unsigned int n = gensetdyn_iter_nocancel(g, g->storage.len, f, stuff) ;
  if (n < g->storage.len)
  {
    int e = errno ;
    gensetdyn_iter_nocancel(g, n, cancelf, stuff) ;
    errno = e ;
    return 0 ;
  }
  return 1 ;
}