logoalt Hacker News

nusarutoday at 2:39 PM1 replyview on HN

Why not use an arena allocator?


Replies

IshKebabtoday at 4:41 PM

Tbh I don't know enough Zig to answer that. Can you give an example? E.g. some non-performance-sensitive function that returns a string? In Rust and C++ you can treat the string exactly the same as you would an integer and it's super easy.

In C you have pain. Does the caller allocate a buffer? How does it know how big to make it? Do you have to have separate calls to calculate the required length? Etc. Can Zig work like Rust/C++ and not like C? My impression is that it can't.

show 1 reply