From ab98afe68b111118907ff89131f0c2cc8e0aef9a Mon Sep 17 00:00:00 2001 From: Jozef Grajciar Date: Wed, 17 Oct 2018 21:05:40 +0200 Subject: [PATCH] Catch::LeakDetector: added cleanup call to destructor simple code with provided main function which just returns 0 leaks memory due to fact that singletons are not cleaned up running valgrind on such simple application reports that 752 bytes are still available in 11 blocks this commit adds destructor to Catch::LeakDetector which calls Catch::cleanUp() --- include/internal/catch_leak_detector.cpp | 5 +++++ include/internal/catch_leak_detector.h | 1 + 2 files changed, 6 insertions(+) diff --git a/include/internal/catch_leak_detector.cpp b/include/internal/catch_leak_detector.cpp index dd160d9c..7a30e8a1 100644 --- a/include/internal/catch_leak_detector.cpp +++ b/include/internal/catch_leak_detector.cpp @@ -6,6 +6,7 @@ */ #include "catch_leak_detector.h" + #include "catch_interfaces_registry_hub.h" #ifdef CATCH_CONFIG_WINDOWS_CRTDBG @@ -30,3 +31,7 @@ namespace Catch { Catch::LeakDetector::LeakDetector() {} #endif + +Catch::LeakDetector::~LeakDetector() { + Catch::cleanUp(); +} diff --git a/include/internal/catch_leak_detector.h b/include/internal/catch_leak_detector.h index bfb0b429..633457ac 100644 --- a/include/internal/catch_leak_detector.h +++ b/include/internal/catch_leak_detector.h @@ -11,6 +11,7 @@ namespace Catch { struct LeakDetector { LeakDetector(); + ~LeakDetector(); }; }