Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/gpgmm/MemoryCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "gpgmm/common/Assert.h"
#include "gpgmm/common/NonCopyable.h"
#include "gpgmm/common/RefCount.h"
#include "gpgmm/common/Utils.h"

#include <unordered_set>

Expand Down Expand Up @@ -187,9 +188,9 @@ namespace gpgmm {
void RemoveAndDeleteAll() {
for (auto it = mCache.begin(); it != mCache.end();) {
if ((*it)->Unref()) {
auto curr = it;
CacheEntryT* item = (*it);
it++;
RemoveCacheEntry(*curr);
SafeDelete(item);
} else {
it++;
}
Expand Down
22 changes: 22 additions & 0 deletions src/tests/GPGMMTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,37 @@
// limitations under the License.

#include "src/tests/GPGMMTest.h"
#include "gpgmm/common/Platform.h"

#include <iostream>

static GPGMMTestEnvironment* gTestEnv = nullptr;

#if defined(GPGMM_PLATFORM_WIN32)
# include <crtdbg.h>
#endif

void ReportMemoryLeaks() {
#if GPGMM_PLATFORM_WIN32
// Send all reports to STDOUT.
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT);
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDOUT);
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT);
// Perform automatic leak checking at program exit through a call to _CrtDumpMemoryLeaks
// and generate an error report if the application failed to free all the memory it
// allocated.
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif
}

GPGMMTestBase::~GPGMMTestBase() {
}

void GPGMMTestBase::SetUp() {
ReportMemoryLeaks();
}

void GPGMMTestBase::TearDown() {
Expand Down