News for hackers. Stuff that matters.
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.
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
Re:Allocgate: Restructuring how allocators work in Zig by fbkr on Wednesday December 15, 2021 @05:49PM (#29572578)
There is no double indirection and allocation here, it stores the FILE* directly, not as a pointer to a FILE*.