I am building a security-critical application and want to ensure that the entire process heap is zeroed out before the program exits ungracefully (I have a kill macro which essentially forcefully exits by calling __builtin_trap or triggering a segfault) and I want to make sure all the secrets are freed before the program exits.
This macro is intended for unrecoverable/very critical failures for example an munlock failure.
What is the best way to implicitly handle this rather than making sure a memory cleanup is done before kill is called?