When my friend had his interview yesterday, he was asked a question: Implement a function that allocates memory space without using the *alloc or new operator, and the function should return a pointer to the address. Neither he nor I can find the answer.
I think the question is more of a puzzle than a question that shows experience with programming. My solution would be allocating a global byte-array, that would be used instead of the heap:
char heap[MAX_ALLOWED_MEM];
/*
The following function uses 'heap' as raw memory!
void* like_malloc(size_t bytes);
...
*/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With