Practice · 2 of 4
Build a Fixed-Size Pool
CHALLENGE
Difficulty: advanced+25 XP
Implement an opaque fixed-block pool:
``c
typedef struct pool pool_t;
pool_t *pool_create(size_t blocks, size_t block_size);
void *pool_get(pool_t *p);
void pool_put(pool_t *p, void *blk);
`
pool_get returns a block or NULL when exhausted; pool_put` returns a block to the free list; a just-returned block must be handed out again first (LIFO).
Press Submit to check your solution.
Back to lesson: Practice: Allocator Engineering Drills