blob: 0fa2944b0384943b2d9668de559c4e2f11046a9b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
/* ISC license. */
#include <sys/types.h>
#include <skalibs/bitarray.h>
size_t bitarray_firstclear_skip (unsigned char const *s, size_t max, size_t skip)
{
size_t i = bitarray_div8(skip) ;
size_t 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) ;
}
|