Fixed-Block Pool Allocator

Problem 11

Fixed-Block Pool Allocator

preview

Implement a fixed-block memory pool in C: pool_init(buf, buf_size, block_size), pool_alloc(), and pool_free(ptr).

Requirements

  1. 01pool_init carves a caller-owned, 8-byte-aligned buffer into floor(buf_size / block_size) fixed-size blocks; block_size is a nonzero multiple of 8.
  2. 02pool_alloc returns one distinct 8-byte-aligned block from the buffer and never allocates from the heap.
  3. 03pool_alloc returns NULL after all blocks are allocated.
  4. 04pool_free returns a previously allocated block so a later allocation can reuse it.

Constraints

  • • Submit one compact engineering spec, not implementation code.
  • • The generated artifact must use the declared C compiler adapter.
  • • Scoring rewards observable behavior and prompt efficiency, not runtime.
Difficulty
expert
Target
12 min
Acceptance
Artifact
library