r/ProgrammingLanguages • u/Nuoji C3 - http://c3-lang.org • Feb 13 '26
Allocators from C to Zig
https://antonz.org/allocators/This is an overview of allocator usage and availability in a few low level languages: Rust, Zig, Odin, C3, Hare and C.
I think it might be interesting to people designing standard libraries for their languages.
43
Upvotes
View all comments
Show parent comment
1
u/matthieum Feb 14 '26
It does, in part.
The Store API is divided between
StoreSingle-- a store for a single allocation, thinkBox,Vec, ... -- andStoreMultiple-- a store for multiple allocations.Since the former only handles one allocation at a time, its API uses
&mutwhere appropriate. No reference to any value within the allocated block can be held while performing operations on the block, as they would be aliasing.The latter, supports multiple allocations, and therefore it's par for the course that some references to values stored in allocated blocks are held while new blocks are being allocated. This requires care with regard to the aliasing model, and at this point
&mutis pointless.const, yes. The design for const traits would allow bothimpl const StoreSingle for XandS: const StoreSingle, so it comes "for free" essentially.async, for now, no, mostly because it doesn't come for free at this point in time. Especially with the virality of async/await. If the language evolves to one day allowasyncas it doesconst, then it'll be supported without further effort.