From 2b0ab2120becaa40b777e7c43bfa57cb0397e3a9 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Tue, 5 Jan 2016 20:04:57 +0000 Subject: Add bitarray_first{clear,set}_skip (thx jjk) version: rc for 2.3.9.0 after Makefile fix --- src/libstddjb/bitarray_firstclear_skip.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/libstddjb/bitarray_firstclear_skip.c (limited to 'src/libstddjb/bitarray_firstclear_skip.c') diff --git a/src/libstddjb/bitarray_firstclear_skip.c b/src/libstddjb/bitarray_firstclear_skip.c new file mode 100644 index 0000000..8a32dba --- /dev/null +++ b/src/libstddjb/bitarray_firstclear_skip.c @@ -0,0 +1,15 @@ +/* ISC license. */ + +#include + +unsigned int bitarray_firstclear_skip (register unsigned char const *s, unsigned int max, unsigned int skip) +{ + register unsigned int i = bitarray_div8(skip) ; + register unsigned int j = i << 3 > max ? max : i << 3 ; + if (i && s[i-1] != 0xffU) + { + while ((skip < j) && bitarray_peek(s, skip)) skip++ ; + if (skip < j) return skip ; + } + return j + bitarray_firstclear(s + i, max - j) ; +} -- cgit v1.3.1