Files
Catch2/src/catch2/internal/catch_leak_detector.cpp
T

39 lines
1.1 KiB
C++
Raw Normal View History

2022-06-21 16:19:50 +02:00
// Copyright Catch2 Authors
// Distributed under the Boost Software License, Version 1.0.
2022-10-28 11:22:53 +02:00
// (See accompanying file LICENSE.txt or copy at
2022-06-21 16:19:50 +02:00
// https://www.boost.org/LICENSE_1_0.txt)
// SPDX-License-Identifier: BSL-1.0
#include <catch2/internal/catch_leak_detector.hpp>
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
#include <catch2/catch_user_config.hpp>
#ifdef CATCH_CONFIG_WINDOWS_CRTDBG
#include <crtdbg.h>
namespace Catch {
LeakDetector::LeakDetector() {
int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
flag |= _CRTDBG_LEAK_CHECK_DF;
flag |= _CRTDBG_ALLOC_MEM_DF;
_CrtSetDbgFlag(flag);
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
// Change this to leaking allocation's number to break there
_CrtSetBreakAlloc(-1);
}
}
#else // ^^ Windows crt debug heap enabled // Windows crt debug heap disabled vv
2023-08-05 18:21:38 +02:00
Catch::LeakDetector::LeakDetector() = default;
2022-06-21 16:19:50 +02:00
#endif // CATCH_CONFIG_WINDOWS_CRTDBG
Catch::LeakDetector::~LeakDetector() {
Catch::cleanUp();
}