Having trouble with my task here. I need to create a global block of free memory and malloc it. Having some trouble initialising it due to typecast and handling errors.
Like arrays in C where the first array is actually a pointer to the first element, my memory block needs to be similar where i can use pointer arithmetic to locate blocks of memory.
//global variable
static byte *memory = NULL;
void allocator_init(u_int32_t size){
*memory = (byte*) malloc(size);
}
The addresses/pointers to these memory addresses will be stored via structs/links as headers of the memory block.
typedef struct _header {
int signiture;
int size;
header* next;
header* prev;
} header;