Implement a Simple Memory Allocator

Problem Implement a simple malloc/free over a fixed pre-allocated arena, using a free list, with block splitting on allocation and coalescing of adjacent free blocks on release.

Input / Output

  • Input: a fixed arena size, then a sequence of alloc(size) and free(ptr) calls.
  • Output: alloc returns an offset/pointer into the arena (or failure); free returns the block to the pool.

Constraints

  • Fixed arena; minimize fragmentation; respect alignment.

Example

  • alloc(16); alloc(32); free(first); alloc(16) reuses the freed block.
added …
LeaderboardSalaryAccount