X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=Common%2Frt%20api%2FMemoryPool.cpp;fp=Common%2Frt%20api%2FMemoryPool.cpp;h=053db7a04b5fff229fe08a321768693291e7f9b9;hb=0fb676244827a448dc60118d6558c4a4e346ffee;hp=1019b4f736212ce01b987e1d9fa729da48240a36;hpb=59bc65eea1e9a2cab6b1d51f4567cffc033fe938;p=freerainbowtables diff --git a/Common/rt api/MemoryPool.cpp b/Common/rt api/MemoryPool.cpp index 1019b4f..053db7a 100644 --- a/Common/rt api/MemoryPool.cpp +++ b/Common/rt api/MemoryPool.cpp @@ -1,8 +1,28 @@ /* - RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique. - - Copyright (C) Zhu Shuanglei -*/ + * freerainbowtables is a project for generating, distributing, and using + * perfect rainbow tables + * + * Copyright (C) Zhu Shuanglei + * Copyright Martin Westergaard Jørgensen + * Copyright 2009, 2010 Daniël Niggebrugge + * Copyright 2009, 2010 James Nobis + * Copyright 2010 uroskn + * + * This file is part of freerainbowtables. + * + * freerainbowtables is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * freerainbowtables is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with freerainbowtables. If not, see . + */ #include "MemoryPool.h" #include "Public.h" @@ -27,7 +47,7 @@ CMemoryPool::~CMemoryPool() { if (m_pMem != NULL) { - delete m_pMem; + delete [] m_pMem; m_pMem = NULL; m_nMemSize = 0; } @@ -50,20 +70,20 @@ unsigned char* CMemoryPool::Allocate(unsigned int nFileLen, unsigned int& nAlloc // Free existing memory if (m_pMem != NULL) { - delete m_pMem; + delete [] m_pMem; m_pMem = NULL; m_nMemSize = 0; } // Allocate new memory //printf("allocating %u bytes memory\n", nTargetSize); -// m_pMem = new unsigned char[nTargetSize]; -m_pMem = new (nothrow) unsigned char[nTargetSize]; -while (m_pMem == NULL && nTargetSize >= 512 * 1024 * 1024 ) -{ - nTargetSize -= 16 * 1024 * 1024; - m_pMem = new (nothrow) unsigned char[nTargetSize]; -} + m_pMem = new (nothrow) unsigned char[nTargetSize]; + while (m_pMem == NULL && nTargetSize >= 512 * 1024 * 1024 ) + { + nTargetSize -= 16 * 1024 * 1024; + m_pMem = new (nothrow) unsigned char[nTargetSize]; + } + if (m_pMem != NULL) { m_nMemSize = nTargetSize; @@ -72,6 +92,7 @@ while (m_pMem == NULL && nTargetSize >= 512 * 1024 * 1024 ) } else { + m_nMemSize = 0; nAllocatedSize = 0; return NULL; }