To start off, the goal with my program is to create my own malloc using the buddy allocation scheme. However, when I go to compile my code, I get the initialization from incompatible pointer type error. I am confused on what exactly this means and how I can fix it. Here is a short snippet of the function where this error is occurring:
node *fList[26] = {NULL};
void *divider(int index, int baseCase) {
node *temporary = fList[index + 1];
int size = ((1 << (index + 6)) / 2);
node *toSplit =(char *)temporary + size; //where error occurs
if(temporary->next != NULL) {
fList[index+1] = temporary->next;
temporary->next= NULL;
fList[index+1]->previous = NULL;
}
else{
fList[index+1]=NULL;
}
temporary->next = toSplit;
toSplit->previous = temporary;
if(fList[index] != NULL){
toSplit->next = fList[index];
fList[index]->previous=toSplit;
}
else{
toSplit->next = NULL;
}
fList[index] = temporary;
temporary->previous=NULL;
temporary->header = index+5;
toSplit->header = index+5;
if(fList[index]->header == baseCase+5){
fList[index]->header |=128;
void *tmp = fList[index];
fList[index]=fList[index]->next;
if(fList[index]!=NULL)
{
fList[index]->previous=NULL;
}
return tmp;
}
else{
divider(index-1,baseCase);
}
}