diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2015-01-10 22:46:45 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2015-01-10 22:46:45 +0000 |
commit | ded707de84a7b1f36a395299ff945c2b2e069bff (patch) | |
tree | e112417452906b085fd991910c261a002536fd58 /src/libdatastruct/gensetdyn_iter.c | |
parent | b7c6bde2b64dcea4e6d272b11dd111b704309f93 (diff) | |
download | skalibs-ded707de84a7b1f36a395299ff945c2b2e069bff.tar.xz |
Gnfrlbl... gensetdyn_iter is an unsigned int again, but the value
is now tested against gensetdyn_n(g). It's cleaner, I swear.
Diffstat (limited to 'src/libdatastruct/gensetdyn_iter.c')
-rw-r--r-- | src/libdatastruct/gensetdyn_iter.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/libdatastruct/gensetdyn_iter.c b/src/libdatastruct/gensetdyn_iter.c index 586aa11..b4e1638 100644 --- a/src/libdatastruct/gensetdyn_iter.c +++ b/src/libdatastruct/gensetdyn_iter.c @@ -10,17 +10,17 @@ unsigned int gensetdyn_iter_nocancel (gensetdyn *g, unsigned int n, iterfunc_t_r XXX: we may be called by a freeing function, so we cannot alloc - XXX: so pray that the bitarray fits in the stack. */ - unsigned char bits[bitarray_div8(n)] ; - unsigned int i = 0, j = 0, m = gensetdyn_n(g) ; + unsigned char bits[bitarray_div8(g->storage.len)] ; + unsigned int i = 0, j = 0 ; register unsigned int *fl = genalloc_s(unsigned int, &g->freelist) ; register unsigned int sp = genalloc_len(unsigned int, &g->freelist) ; - bitarray_setn(bits, 0, n) ; + bitarray_setn(bits, 0, g->storage.len) ; - for (; i < sp ; i++) if (fl[i] < n) bitarray_clear(bits, fl[i]) ; - for (i = 0 ; (i < n) && (j < m) ; i++) if (bitarray_peek(bits, i)) + for (; i < sp ; i++) if (fl[i] < g->storage.len) bitarray_clear(bits, fl[i]) ; + for (i = 0 ; (i < g->storage.len) && (j < n) ; i++) if (bitarray_peek(bits, i)) { j++ ; if (!(*f)(gensetdyn_p(g, i), stuff)) break ; } - return i ; + return j ; } |