TEST(TestMemoryAllocatorTest, SetCurrentMallocAllocator) { allocator = new TestMemoryAllocator("malloc_allocator"); setCurrentMallocAllocator(allocator); POINTERS_EQUAL(allocator, getCurrentMallocAllocator()); setCurrentMallocAllocatorToDefault(); POINTERS_EQUAL(defaultMallocAllocator(), getCurrentMallocAllocator()); }
void MemoryReporterPlugin::removeGlobalMemoryReportAllocators() { if (getCurrentNewAllocator() == &newAllocator) setCurrentNewAllocator(newAllocator.getRealAllocator()); if (getCurrentNewArrayAllocator() == &newArrayAllocator) setCurrentNewArrayAllocator(newArrayAllocator.getRealAllocator()); if (getCurrentMallocAllocator() == &mallocAllocator) setCurrentMallocAllocator(mallocAllocator.getRealAllocator()); }
void MemoryReporterPlugin::setGlobalMemoryReportAllocators() { mallocAllocator.setRealAllocator(getCurrentMallocAllocator()); setCurrentMallocAllocator(&mallocAllocator); newAllocator.setRealAllocator(getCurrentNewAllocator()); setCurrentNewAllocator(&newAllocator); newArrayAllocator.setRealAllocator(getCurrentNewArrayAllocator()); setCurrentNewArrayAllocator(&newArrayAllocator); }
static void* mem_leak_realloc(void* memory, size_t size, const char* file, int line) { return MemoryLeakWarningPlugin::getGlobalDetector()->reallocMemory(getCurrentMallocAllocator(), (char*) memory, size, file, line, true); }
static void mem_leak_free(void* buffer, const char* file, int line) { MemoryLeakWarningPlugin::getGlobalDetector()->invalidateMemory((char*) buffer); MemoryLeakWarningPlugin::getGlobalDetector()->deallocMemory(getCurrentMallocAllocator(), (char*) buffer, file, line, true); }