smalloc: a simple memory allocator

35 points by asb


andrewrk

You can make it even simpler if you design the allocator interface carefully:

https://codeberg.org/ziglang/zig/src/commit/0.15.2/lib/std/heap/SmpAllocator.zig

This is it. Less than 200 lines in 1 file, and it's competitive with glibc.

Main difference vs malloc/free is the user is required to track length and alignment, which is generally information statically known by the type system.