blob: 1c39582b93368d14b6c8eda33086a06104077a56 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
/* ISC license. */
#include <skalibs/bitarray.h>
size_t bitarray_firstset_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])
{
while ((skip < j) && !bitarray_peek(s, skip)) skip++ ;
if (skip < j) return skip ;
}
return j + bitarray_firstset(s + i, max - j) ;
}
|