bitset_t *ptr = area;
memset(area, 0, _bitset_overall_size(sizeof(bitset_t), size));
ptr->units = _bitset_units(size);
bitset_t *ptr = area;
memset(area, 0, _bitset_overall_size(sizeof(bitset_t), size));
ptr->units = _bitset_units(size);
bitset_pos_t pos, int set)
{
bitset_pos_t unit_number = pos / BS_UNIT_SIZE_BITS;
bitset_pos_t pos, int set)
{
bitset_pos_t unit_number = pos / BS_UNIT_SIZE_BITS;
_bitset_inside_ntz_value((set ? curr_unit : ~curr_unit) & ~in_unit_mask);
/* If there is a bit set in the current unit, exit. */
_bitset_inside_ntz_value((set ? curr_unit : ~curr_unit) & ~in_unit_mask);
/* If there is a bit set in the current unit, exit. */
- if(next_in_this_unit < BS_UNIT_SIZE_BITS)
- return next_in_this_unit + unit_number * BS_UNIT_SIZE_BITS;
+ if (next_in_this_unit < BS_UNIT_SIZE_BITS) {
+ res = next_in_this_unit + unit_number * BS_UNIT_SIZE_BITS;
+ return res < bs->size ? res : -1;
+ }
- if(first_set < BS_UNIT_SIZE_BITS)
- return first_set + i * BS_UNIT_SIZE_BITS;
+ if (first_set < BS_UNIT_SIZE_BITS) {
+ res = first_set + i * BS_UNIT_SIZE_BITS;
+ return res < bs->size ? res : -1;
+ }