void FailableMemoryAllocator::clearFailedAllocs()
{
    toFailCount_ = 0;
    locationToFailCount_ = 0;
    currentAllocNumber_ = 0;
    PlatformSpecificMemset(allocsToFail_, 0, sizeof(allocsToFail_));
    PlatformSpecificMemset(locationAllocsToFail_, 0, sizeof(locationAllocsToFail_));
}
FailableMemoryAllocator::FailableMemoryAllocator(const char* name_str, const char* alloc_name_str, const char* free_name_str)
: TestMemoryAllocator(name_str, alloc_name_str, free_name_str)
, toFailCount_(0), locationToFailCount_(0), currentAllocNumber_(0)
{
    PlatformSpecificMemset(allocsToFail_, 0, sizeof(allocsToFail_));
    PlatformSpecificMemset(locationAllocsToFail_, 0, sizeof(locationAllocsToFail_));

}
TEST(BasicBehavior, deleteArrayInvalidatesMemory)
{
	unsigned char* memory = new unsigned char[10];
	PlatformSpecificMemset(memory, 0xAB, 10);
	delete [] memory;
	CHECK(memory[5] != 0xCB);
}
Example #4
0
void* cpputest_calloc_location(size_t num, size_t size, const char* file, int line)
{
    void* mem = cpputest_malloc_location(num * size, file, line);
    if (mem)
        PlatformSpecificMemset(mem, 0, num*size);
    return mem;
}
void MemoryLeakDetector::invalidateMemory(char* memory)
{
  MemoryLeakDetectorNode* node = memoryTable_.retrieveNode(memory);
  if (node)
    PlatformSpecificMemset(memory, 0xCD, node->size_);
}