bitarray_firstclear.c (320B)
1 /* ISC license. */ 2 3 #include <skalibs/bitarray.h> 4 5 size_t bitarray_firstclear (unsigned char const *s, size_t max) 6 { 7 size_t n = bitarray_div8(max) ; 8 size_t i = 0 ; 9 for (; i < n ; i++) if (s[i] != 0xffU) break ; 10 if (i == n) return max ; 11 i <<= 3 ; 12 while ((i < max) && bitarray_peek(s, i)) i++ ; 13 return i ; 14 }