I'm writing software to simulate the "first-fit" memory allocation schema.
Basically, I allocate a large X megabyte chunk of memory and subdivide it into blocks when chunks are requested according to the schema.
I'm using a linked list called "node" as a header for each block of memory (so that we can find the next block without tediously looping through every address value.
head_ptr = (char*) malloc(total_size + sizeof(node));
if(head_ptr == NULL) return -1; // Malloc Error .. :-(
node* head_node = new node; // Build block header
head_node->next = NULL;
head_node->previous = NULL;
// Header points to next block (which doesn't exist yet)
memset(head_ptr,head_node, sizeof(node));
`
But this last line returns:
error: invalid conversion from 'node*' to 'int'
I understand why this is invalid.. but how can I place my node into the pointer location of my newly allocated memory?