diff options
author | Tobias Müller <Tobias_Mueller@twam.info> | 2019-03-15 14:11:10 +0100 |
---|---|---|
committer | Tobias Müller <Tobias.Mueller9@de.bosch.com> | 2019-03-19 09:29:48 +0100 |
commit | c3ac2655f7e559dbca0d4677e4da48a92cf84dd6 (patch) | |
tree | d777768ade18527f9e4000d567216d5530da9fee | |
parent | 8b6d3f9c4a774bef3081195d422993323b6bb2e0 (diff) | |
download | googletest-c3ac2655f7e559dbca0d4677e4da48a92cf84dd6.tar.gz googletest-c3ac2655f7e559dbca0d4677e4da48a92cf84dd6.tar.bz2 googletest-c3ac2655f7e559dbca0d4677e4da48a92cf84dd6.zip |
Remove old_crtdbg_flag_ member if not required
-rw-r--r-- | googletest/src/gtest-port.cc | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc index ca7136ac..587ca0a5 100644 --- a/googletest/src/gtest-port.cc +++ b/googletest/src/gtest-port.cc @@ -380,6 +380,7 @@ void Mutex::AssertHeld() { namespace { +#ifdef _MSC_VER // Use the RAII idiom to flag mem allocs that are intentionally never // deallocated. The motivation is to silence the false positive mem leaks // that are reported by the debug version of MS's CRT which can only detect @@ -392,19 +393,15 @@ class MemoryIsNotDeallocated { public: MemoryIsNotDeallocated() : old_crtdbg_flag_(0) { -#ifdef _MSC_VER old_crtdbg_flag_ = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); // Set heap allocation block type to _IGNORE_BLOCK so that MS debug CRT // doesn't report mem leak if there's no matching deallocation. _CrtSetDbgFlag(old_crtdbg_flag_ & ~_CRTDBG_ALLOC_MEM_DF); -#endif // _MSC_VER } ~MemoryIsNotDeallocated() { -#ifdef _MSC_VER // Restore the original _CRTDBG_ALLOC_MEM_DF flag _CrtSetDbgFlag(old_crtdbg_flag_); -#endif // _MSC_VER } private: @@ -412,6 +409,7 @@ class MemoryIsNotDeallocated GTEST_DISALLOW_COPY_AND_ASSIGN_(MemoryIsNotDeallocated); }; +#endif // _MSC_VER } // namespace @@ -427,7 +425,9 @@ void Mutex::ThreadSafeLazyInit() { owner_thread_id_ = 0; { // Use RAII to flag that following mem alloc is never deallocated. +#ifdef _MSC_VER MemoryIsNotDeallocated memory_is_not_deallocated; +#endif // _MSC_VER critical_section_ = new CRITICAL_SECTION; } ::InitializeCriticalSection(critical_section_); @@ -670,7 +670,9 @@ class ThreadLocalRegistryImpl { // Returns map of thread local instances. static ThreadIdToThreadLocals* GetThreadLocalsMapLocked() { mutex_.AssertHeld(); +#ifdef _MSC_VER MemoryIsNotDeallocated memory_is_not_deallocated; +#endif // _MSC_VER static ThreadIdToThreadLocals* map = new ThreadIdToThreadLocals(); return map; } |