Seriously. You get these tests for free with zig, no extra tooling, if you use testing allocator in your tests. This also is a carrot to get you to write tests. Hell, I even mocked libc's malloc/calloc/free to make sure that my code doesn't leak memory:
https://github.com/ityonemo/Primes/blob/ee81d05e80d68854ab11...
> It is the Zig programmer's responsibility to ensure that a pointer is not accessed when the memory pointed to is no longer available.
https://ziglang.org/documentation/0.8.1/#Memory
Mocking malloc you say?
https://docs.microsoft.com/en-us/visualstudio/debugger/crt-d...
It exists at very least since Visual C++ 5.0, and Borland had similar tooling since their first Win16 compilers.
Yes, your examples are two proprietary, nonstandard techniques. Or alternatively using a third-class toolset (jemalloc toolkit e.g ).
Sanity is having a single, anointed way to do it in the stdlib.