void *malloc(int size) {
static long nextAddress = BASE_ADDRESS;
void *ptr = (void *)nextAddress;
nextAddress += size;
return ptr;
}
void free(void *ptr) {
return;
}
Using that will last you a long time in writing a toy operating system kernel. Of course, it will eventually run out of memory pages, but that shouldn't happen until your system has been running for a long time.