Why is mem_size defined as “Minimum expected size of bitmap”? The code looks strange to me.
It will return an error if you pass in 2KB of memory to hold a 1KB bitmap, but not if you pass in 2KB of memory to hold a 4KB bitmap. Shouldn’t it be the other way around? -Andrew