Back to problems

Implement malloc and free with Free-Block Indexing

Object-Oriented Programming · OpenAI · Hard

Build a simplified memory allocator that supports two operations, malloc and free. Start with a straightforward implementation, then improve how free blocks are located and merged. The managed memory has a total capacity of N, and every address is an integer in the range $$[0, N)$$. At the start, the entire range is free. Every allocation must be a single contiguous interval of addresses. Real pointers, alignment, concurrency and the actual bytes stored in memory are all…

Loading the rest of the question…