1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
void* MemoryManager::allocate(size_t size, const char* file, unsigned int line, bool anArray)
{
mNumNewCalls++;
// Allocation of the memory
void* ptr = malloc(size);
// Adding the block to the list of allocated blocks
ST_Block newMemoryBlock;
//newMemoryBlock.address = &ptr;
newMemoryBlock.size = size;
newMemoryBlock.file = file;
newMemoryBlock.line = line;
newMemoryBlock.anArray = anArray;
mBlocks[ptr] = newMemoryBlock;
mAllocationsReport.push_back(newMemoryBlock);
// Keep track of number of allocated blocks and bytes.
mNumBlocks++;
mNumBytes += size;
return ptr;
} |