I am writing my own malloc () and I already understood the following
struct myblock { struct myblock *next; struct myblock *prev; int isFree; unsigned availablesize; char *buffer; }
and the space #define MEM_BUFFER (1024), which will be "my bar". and if I'm not mistaken, I will have
char *array[MEM_BUFFER];
to have an array of 1024 bytes (kindly correct me if I am wrong).
As we know, MEM_BUFFER will also contain the matadata of the occupied space. I'm a little confused on how to get started.
This is my main question. Should the structure be assigned to an array for each distribution request (if so, from an array of struct char?).
Do I have to process a double linked list on the heap and bypass sizeof (myblock) bytes from the array.
I have been thinking about this decision for the past 2 days, and I'm still confused.
source share