I am writing an memory allocator that is backed by a bit map (array of uint8_t
) currently when an allocation request comes along I scan the bitmap sequential from 0 to n bits and search for a space that can fulfill the request. (a bit 1 denotes page used a 0 denoted page is free) Now instead of searching for a space one bit at a time is there technique to scan the whole array faster? i.e if a request for 3 page memory arrives I would like to search for 000
pattern in the array in one go ideally without looping?
PS: I am not using std::bitset
as it is not available for the compiler I am using. AFAIK that does not let me search for multiple bits also.
EDIT: Bits are packed into bytes one uint8_t
has 8 pages (1 per bit) encoded in it.