(no title)
alchemio | 1 year ago
Similarly zig’s stdlib shouldn’t allocate behind your back, except for thread spawn where it does: https://github.com/ziglang/zig/blob/5cd7fef17faa2a40c8da23f0...
Generally speaking, it’s as mentioned just a convention. A zig library might not allow its users to pass allocators for example.
In C++, stl containers can take an allocator as a template parameter. Recent C++ versions also provide several polymorphic allocators in the stdlib. You can also override the global allocator or a specific class’ allocator (override placement new).
AndyKelley|1 year ago
You also linked specifically to the POSIX threads implementation of thread spawning, which is by definition supposed to play nicely with the libc posix threads API, which expects you to use the libc allocator in combination with POSIX threads API, so that's what it does.
You might as well accuse the mmap() function in the zig standard library of allocating behind your back.
alchemio|1 year ago
1. https://ziglang.org/learn/why_zig_rust_d_cpp/#no-hidden-allo...
MindSpunk|1 year ago
fsckboy|1 year ago
jcelerier|1 year ago
Does it really matter when people were already writing code with strdup when the zig and rust creators were in middle school ? It was already there in BSD 4.3 (1986) apparently.
uecker|1 year ago
Everything old is new again...
alchemio|1 year ago