3 ms·
> As for hidden allocations, the only hidden allocation I know of was C's now deprecated runtime length array. I believe there's plenty of functions in C's std
by kristoff_it 6y ago
> As for hidden allocations, the only hidden allocation I know of was C's now deprecated runtime length array.
I believe there's plenty of functions in C's stdlib that just call malloc as they please, like localtime, for example.
- Kranar 6y agolocaltime does not do any dynamic allocation and very few C functions do, there's malloc and some string handling functions that do it. Furthermore I am referring to core language, not standard library. Zig also uses dynamic memory in its standard library and any non-trivial standard library will do memory allocation.
- kristoff_it 6y agoThanks for the correction on localtime, but they point is not avoiding allocation completely, is being explicit about it. All functions in Zig's stdlib that allocate memory take an allocator as parameter. That's pretty much the whole point: allowing the programmer to know if a function might allocate or not, and allow them to customize which allocation scheme to use by passing in whatever allocator they prefer.