// memorybuffer.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "memory.h" #include "stdlib.h" class MemoryBuffer { public: MemoryBuffer(MemoryBuffer* source); MemoryBuffer(unsigned int alocatedSize); ~MemoryBuffer(); void* GetBuffer(); unsigned int GetSize(); unsigned int AlocatedSize; private: void* MemoryPointer; }; MemoryBuffer::MemoryBuffer(MemoryBuffer* source) { } void* MemoryBuffer::GetBuffer() { return MemoryPointer; } unsigned int MemoryBuffer::GetSize() { return AlocatedSize; } MemoryBuffer::MemoryBuffer(unsigned int alocatedSize) { AlocatedSize = alocatedSize; MemoryPointer = calloc(alocatedSize, 1); if (MemoryPointer == nullptr) { throw "Out of Memory"; } }; MemoryBuffer::~MemoryBuffer() { free(MemoryPointer); AlocatedSize = 0; MemoryPointer = 0; } int _tmain(int argc, _TCHAR* argv[]) { try { MemoryBuffer mBuffer(16); memset(mBuffer.GetBuffer(), 0, mBuffer.GetSize()); } catch (char* errMsg) { } return 0; }