C/C++ and bitmaps

I've been trying to find a good tutorial that explains from newbie level on how to work with bitmaps. I'm trying to write a malloc() and I *think* this is the best way to go?
 
It is not really clear to what you are referring, I suspect not the bmp file format! What is the problem you are trying to solve?
 
kr651129 probably wants to use bit sequences to indicate page usage. I.e. use 1 Byte to indicate whether and which of 8 consequent pages are currently allocated.

I would recommend using memory segments in interval trees though.

The way "malloc" (or rather memory management as a whole) works in FreeBSD is explained in The Implementation of the FreeBSD Operating System by McKusick and Neville-Neil. I don't know any explicit guide to bitmaps, but thinking about it (and having knowledge about algorithms) will likely help.

EDIT:
C++ offers the std::vector<bool> data structure which is a bitmap.
 
kr651129 said:
I've been trying to find a good tutorial that explains from newbie level on how to work with bitmaps. I'm trying to write a malloc() and I *think* this is the best way to go?

Bitmap is just a simple array with some helper functions, ideally array of units with size of machine's WORD to avoid memory fragmentation. Since computers can not read/write single bit values directly you need to create some helper functions to act as 'getter' and 'setter' in your bitmap by loading each array unit and processing single bit values using bitwise operators. Instead of looking for bitmap tutorials just look up bitwise operators' tutorial to get a better understanding.
 
Well on GIMP, if you save an image as C/C++ header file format, it will show how image file can be (though it doesn't look pretty) represented in struct.
 
Back
Top