c ++ – First fit with a linked list

// Allocate memory using the first algo
void * my_malloc (size_t sz)
{
size_t count = 0;
node_t * prevnode = NULL;
size_t allocate = 0 ;;
header_t * retadd = NULL;

// total size = sz + system time (due to size quantization in sizeof (header_t))
// allocate = ((sz + ALIGN - 1) / ALIGN + 1) * ALIGN;
allocs = (sz + ALIGN - 1) & ~ (ALIGN-1);
if (allocsz> MYHEAPSIZE) returns NULL;
// make sure no less than the specific amount is allocated to minimize frag
if (allocsz <2 * sizeof (header_t)) allocsz = 2 * sizeof (header_t);

// find the first block larger than or equal to sz
// start the search next to the newly assigned block
while (count < freelist.len ) {
        prevnode = freelist.curr;
        freelist.curr = freelist.curr->header.s.next;
if (freelist.curr-> header.s.size == allocsz) {
// found a block, remove it from the list to provide the requested memory
if (freelist.len == 1) {
// special treatment if only one node is present
retadd = freelist.curr-> retaddress;

freelist.first = NULL;
freelist.last = NULL;
freelist.curr = NULL;
freelist.len--;
Pause;
}
other {
retadd = freelist.curr-> retaddress;
if (freelist.curr == freelist.first) {
freelist.first = freelist.curr-> header.s.next;
}
else if (freelist.curr == freelist.last) {
freelist.last = freelist.curr-> header.s.next;
}
freelist.curr = prevnode-> header.s.next = freelist.curr-> header.s.next;
freelist.len--;
Pause;
}
}
else if (freelist.curr-> header.s.size> sz) {
// found a block, reduce it by removing the end of the required memory
freelist.curr-> header.s.size - = allocsz;
retadd = (header_t *) ((char *) freelist.curr + freelist.curr-> header.s.size);
retadd-> s.size = allocsz;
retadd = (header_t *) ((char *) retadd + sizeof (header_t));
Pause;

}
count ++;
}
printf ("reqsz =% u, allocsz =% u, add =% p  n", (unsigned) sz, (unsigned) allocsz, retadd);

if (retadd == NULL) {
printf ("OUT OF MEMORY  n");
}

return (void *) retadd;
}

// I'm a beginner. I'm getting this error online retadd = freelist.curr-> retaddress;
[Error] Invalid conversion of 'void * & # 39; at & # 39; header_t * & # 39; [-fpermissive]