Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "cMemory.h"
- #include <Windows.h>
- cMemory::cMemory()
- {
- mBlockId = 0;
- mBlockSize = 10;
- mBlockCount = 1024;
- mPosInBlock = 0;
- //memset(mBlocks, NULL,mBlockCount* sizeof(char*))
- mBlocks = new char*[mBlockCount];
- for (size_t i = 0; i < mBlockCount - 1; i++)
- {
- mBlocks[i] = NULL;
- }
- }
- cMemory::~cMemory()
- {
- for (size_t i = 0; i < mBlockId; i++)
- {
- delete mBlocks[i];
- }
- delete mBlocks;
- }
- char * cMemory::New(int size)
- {
- if (mPosInBlock + size > mBlockSize)
- {
- mBlockId++;
- mPosInBlock = 0;
- mBlocks[mBlockId] = new char[mBlockSize*sizeof(char*)];
- }
- char *p = mBlocks[mBlockId] + mPosInBlock;
- mPosInBlock += size;
- return p;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement