Adobe Interview Question: Malloc is used to allocate me... |

Interview Question

Computer Scientist Interview

Malloc is used to allocate memory. write a simplistic void

  * malloc(length) * free(void*) which work efficiently.

Interview Answer

2 Answers


the interviewer essentially wants to hear about a simplistic O(1) way.

my answer was to store the length of allocated memory in first 4 bytes and return the 4th byte whenever allocating.

while deallocating a previously void * ; go back 4 bytes, read its length and free up length+4 bytes. this will make deallocation a constant time operation.

Interview Candidate on 14-Aug-2010

Do you have a question about Adobe? Don't ask just anyone for information, ask an employee from Adobe. They're all waiting at Rooftop Slushie.

Anonymous on 13-Aug-2019

Add Answers or Comments

To comment on this, Sign In or Sign Up.