Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-09-15 06:23:06 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-09-15 06:32:00 +0300
commit62f2925e438fae25f0dab615a7932774586669f3 (patch)
treedf2ba7195a0defc1fe35126b4f641832bbe96496 /intern/guardedalloc
parent2120acb73e4a76543d83247ed45c95990d705d64 (diff)
Fix T80774: (correction) keep MEM_init_memleak_detection call early
Diffstat (limited to 'intern/guardedalloc')
-rw-r--r--intern/guardedalloc/MEM_guardedalloc.h6
-rw-r--r--intern/guardedalloc/intern/leak_detector.cc9
2 files changed, 15 insertions, 0 deletions
diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h
index 71d3c512306..78e629a6971 100644
--- a/intern/guardedalloc/MEM_guardedalloc.h
+++ b/intern/guardedalloc/MEM_guardedalloc.h
@@ -215,6 +215,12 @@ extern const char *(*MEM_name_ptr)(void *vmemh);
* about memory leaks will be printed on exit. */
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
* tests. */
diff --git a/intern/guardedalloc/intern/leak_detector.cc b/intern/guardedalloc/intern/leak_detector.cc
index 0ecf2ed8ba7..fb8d4e72cac 100644
--- a/intern/guardedalloc/intern/leak_detector.cc
+++ b/intern/guardedalloc/intern/leak_detector.cc
@@ -32,11 +32,15 @@ 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) {
@@ -74,6 +78,11 @@ void MEM_init_memleak_detection(void)
static MemLeakPrinter printer;
}
+void MEM_use_memleak_detection(bool enabled)
+{
+ ignore_memleak = !enabled;
+}
+
void MEM_enable_fail_on_memleak(void)
{
fail_on_memleak = true;