4 ms·
I have a much better and practical solution: https://github.com/LibreDWG/libredwg/blob/7d9fc3da44bbdb60a40d2dabd167341462434362/programs/dwgread.c#L327 https://
by rurban 3y ago
I have a much better and practical solution: https://github.com/LibreDWG/libredwg/blob/7d9fc3da44bbdb60a40d2dabd167341462434362/programs/dwgread.c#L327 https://github.com/LibreDWG/libredwg/blob/7d9fc3da44bbdb60a4...
#ifdef HAVE_VALGRIND_VALGRIND_H
if (RUNNING_ON_VALGRIND)
#endif
free_all()
free is way too slow if not needed, so detect valgrind via its API. Just on valgrind do the unnecessary free dance. ASAN's memleak detector is disabled via its env.
Perl5 does its final destruction similarly, only when it has important destructors (like IO, DB handles and such) to call.
- cesarb 3y agoThat style of #ifdef use, while common in the past, tends to be somewhat fragile and also gets more and more tangled as more conditions are added. A better way is to have an always existing inline running_on_valgrind() function, and use the #ifdef only for that function definition, either within it or around it (having it around the function also allows it to be inline only for the trivial not-defined case). Examples of this "inline function" style are found all over the Linux kernel (which has lots of conditionally-compiled code).