Core: always free memory on exit, always report leaks
Instead of allowing leaks when parsing arguments, always cleanup before calling exit(). This impacts -a (animation player), --help & --version arguments, as well as scripts executed via --python which meant tests that ran scripts could leak memory without raising an error as intended. Avoid having suppress warnings & rationalize in code-comments when leaking memory is/isn't acceptable, any leaks from the animation-player are now reported as well. This change exposed leaks: !140182, !140116. Ref !140098
This commit is contained in:
@@ -269,12 +269,6 @@ extern void (*MEM_name_ptr_set)(void *vmemh, const char *str) ATTR_NONNULL();
|
||||
*/
|
||||
void MEM_init_memleak_detection(void);
|
||||
|
||||
/**
|
||||
* Use this if we want to call #exit during argument parsing for example,
|
||||
* without having to free all data.
|
||||
*/
|
||||
void MEM_use_memleak_detection(bool enabled);
|
||||
|
||||
/**
|
||||
* When this has been called and memory leaks have been detected, the process will have an exit
|
||||
* code that indicates failure. This can be used for when checking for memory leaks with automated
|
||||
|
||||
@@ -24,15 +24,11 @@ char free_after_leak_detection_message[] =
|
||||
namespace {
|
||||
|
||||
bool fail_on_memleak = false;
|
||||
bool ignore_memleak = false;
|
||||
|
||||
class MemLeakPrinter {
|
||||
public:
|
||||
~MemLeakPrinter()
|
||||
{
|
||||
if (ignore_memleak) {
|
||||
return;
|
||||
}
|
||||
leak_detector_has_run = true;
|
||||
const uint leaked_blocks = MEM_get_memory_blocks_in_use();
|
||||
if (leaked_blocks == 0) {
|
||||
@@ -83,11 +79,6 @@ void MEM_init_memleak_detection()
|
||||
static MemLeakPrinter printer;
|
||||
}
|
||||
|
||||
void MEM_use_memleak_detection(bool enabled)
|
||||
{
|
||||
ignore_memleak = !enabled;
|
||||
}
|
||||
|
||||
void MEM_enable_fail_on_memleak()
|
||||
{
|
||||
fail_on_memleak = true;
|
||||
|
||||
Reference in New Issue
Block a user