Skip to main content

Checkpoint: Aligned Arena

Challenge on lesson: Checkpoint: Arena with Alignment

CHALLENGE
Difficulty: advanced+25 XP

Implement the arena with one addition โ€” aligned allocation: ``c typedef struct { unsigned char *mem; size_t cap; size_t used; } arena_t; void arena_init(arena_t *a, unsigned char *buf, size_t cap); void *arena_alloc_aligned(arena_t *a, size_t n, size_t align); size_t arena_used(const arena_t *a); void arena_reset(arena_t *a); ` arena_alloc_aligned first aligns the current offset up to align (power of two), then places the slice; returns NULL if it cannot fit. arena_used reports current used`.

Back to lesson: Checkpoint: Arena with Alignment