39 uint8_t
block[
sizeof(uint8_t *)];
51 if (size_bits <=
sizeof(ba.
u.
block) * 8) {
56 size_t capacity = size_bits / 8 + (size_bits % 8 == 0 ? 0 : 1);
65 assert(index < self.
size_bits &&
"out of bounds access");
75 return (base[index / 8] >> (index % 8)) & 1;
80 assert(index < self->size_bits &&
"out of bounds access");
91 base[index / 8] |= (uint8_t)(UINT8_C(1) << (index % 8));
93 base[index / 8] &= (uint8_t)~(UINT8_C(1) << (index % 8));
Memory allocation wrappers that exit on failure.
static void * gv_calloc(size_t nmemb, size_t size)
static bitarray_t bitarray_new(size_t size_bits)
create an array of the given element length
static bool bitarray_get(bitarray_t self, size_t index)
get the value of the given element
static void bitarray_set(bitarray_t *self, size_t index, bool value)
set or clear the value of the given element
static void bitarray_reset(bitarray_t *self)
free underlying resources and leave a bit array empty
uint8_t block[sizeof(uint8_t *)]
inline storage for small arrays
size_t size_bits
extent in bits
uint8_t * base
start of the underlying allocated buffer