Master the fundamental concepts of rust for systems programming through this focused micro-challenge.
Rust routes global allocation through GlobalAlloc. Discord and others plug in jemalloc or mimalloc for fleet wins; embedded targets sometimes ship a bump allocator with no individual free. Your exercise implements the trait the standard library expects.
rustLoading…
size and align; both must be honored on returnalloc#[global_allocator]Align an offset with (offset + align - 1) & !(align - 1), bump past the allocation, never free until reset. Zero-sized layouts are valid edge cases.
For this exercise, you will implement a GlobalAlloc bump allocator on a fixed byte array. This task asks you to pass Layout through correctly, because misaligned returns corrupt Vec growth and produce impossible-to-debug segfaults deep inside std.
Keep the relevant man page, ABI doc, or Rust reference chapter open while you work. When your output disagrees with the reference implementation on the same machine, the mismatch is usually an alignment rule, an off-by-one terminator, or a register slot you misread in GDB.
Implement a custom allocator using the GlobalAlloc trait in Rust.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github