2 ms·
> Oh, you want to malloc a chunk of heap, free it 8 calls deep in some random function, and then pinky swear never to touch it again? There is no default syste
by bsder 2y ago
> Oh, you want to malloc a chunk of heap, free it 8 calls deep in some random function, and then pinky swear never to touch it again?
There is no default system memory allocator in Zig--this is a signficant difference between Zig and C or Rust.
If you want to allocate in Zig, you have to cough up an allocator and pass it around.
The downside is that a lot of things need an allocator and that makes some things more complicated (printing to console, for example). The upside is that if there is no allocator being passed, you're guaranteed to not be allocating/deallocating memory.