Re:Allocgate: Restructuring how allocators work in Zig
by 10000truths on Wednesday December 15, 2021 @04:54PM
(#29572085)
Now you have a double indirection. Worse, the handle probably already references dynamically allocated memory. So that’s two dynamic memory allocations per “safe” handle. Which might be perfectly acceptable for non-critical programs, but it is certainly going to tank your memory usage efficiency and thrash your CPU cache if scaled up to millions of handles.
[ Parent
| on HN ]
Re:Allocgate: Restructuring how allocators work in Zig
by jcelerier on Wednesday December 15, 2021 @06:02PM
(#29572678)
This is entirely wrong.
This produces exactly the same code than
auto f = fopen("foo", "r");
if(f)
fclose(f);
check for yourself: https://gcc.godbolt.org/z/YxaPqYGez