Memory Pool with Free List

Hard C Memory Asked at Micron
Solve this problem

Build a fixed-block memory pool with an intrusive free list. Allocation and release must both be O(1) and must not fragment.

Constraints

  • Pool is 32 blocks of 64 bytes, statically allocated.
  • `void *pool_alloc(void)` returns NULL when exhausted.
  • `void pool_free(void *block)` returns a block to the list.
  • The free list must live inside the free blocks themselves - no side table.
  • pool_free(NULL) must be a no-op.
  • No malloc, no calloc.
Starter codeC
1#include <stddef.h>2 3#define BLOCK_SIZE 644#define BLOCK_COUNT 325 6void pool_init(void);7void *pool_alloc(void);8void pool_free(void *block);