diff options
author | Gennadiy Civil <misterg@google.com> | 2019-03-21 10:43:14 -0400 |
---|---|---|
committer | Gennadiy Civil <misterg@google.com> | 2019-03-21 10:43:14 -0400 |
commit | 10e98c4f2a0176590c10e4f83f5d048c167f32d0 (patch) | |
tree | 4eb1f7a1d0b2a166539b33a38a400e99c6b65bad | |
parent | f1883b1824109338db40837bdb61f0150e395bb7 (diff) | |
parent | c3ac2655f7e559dbca0d4677e4da48a92cf84dd6 (diff) | |
download | googletest-10e98c4f2a0176590c10e4f83f5d048c167f32d0.tar.gz googletest-10e98c4f2a0176590c10e4f83f5d048c167f32d0.tar.bz2 googletest-10e98c4f2a0176590c10e4f83f5d048c167f32d0.zip |
Merge pull request #2180 from twam:master
PiperOrigin-RevId: 239404016
-rw-r--r-- | googlemock/docs/DesignDoc.md | 1 | ||||
-rw-r--r-- | googletest/src/gtest-port.cc | 10 |
2 files changed, 6 insertions, 5 deletions
diff --git a/googlemock/docs/DesignDoc.md b/googlemock/docs/DesignDoc.md index d13ff5b9..4cddc9d0 100644 --- a/googlemock/docs/DesignDoc.md +++ b/googlemock/docs/DesignDoc.md @@ -198,7 +198,6 @@ Google Test (the name is chosen to match `static_assert` in C++0x). If you are writing a function that returns an `ACTION` object, you'll need to know its type. The type depends on the macro used to define the action and the parameter types. The rule is relatively simple: - | **Given Definition** | **Expression** | **Has Type** | |:-------------------------|:-----------------------------|:-------------------------| | `ACTION(Foo)` | `Foo()` | `FooAction` | 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; } |