Fixed: Memory leaks in CBigFile

This commit is contained in:
kervala 2016-12-04 16:54:57 +01:00
parent e9328811af
commit ec0222958f
2 changed files with 26 additions and 3 deletions

View file

@ -112,7 +112,8 @@ public:
// A BNP structure
struct BNP
{
BNP() : FileNames(NULL), ThreadFileId(0), CacheFileOnOpen(false), AlwaysOpened(false), InternalUse(false), OffsetFromBeginning(0) { }
BNP();
~BNP();
// FileName of the BNP. important to open it in getFile() (for other threads or if not always opened).
std::string BigFileName;
@ -163,6 +164,7 @@ private:
{
public:
CThreadFileArray();
~CThreadFileArray();
// Allocate a FileId for a BNP.
uint32 allocate();

View file

@ -45,8 +45,16 @@ void CBigFile::releaseInstance()
// ***************************************************************************
CBigFile::CThreadFileArray::CThreadFileArray()
{
_CurrentId= 0;
_CurrentId = 0;
}
// ***************************************************************************
CBigFile::CThreadFileArray::~CThreadFileArray()
{
vector<CHandleFile> *ptr = (vector<CHandleFile>*)_TDS.getPointer();
if (ptr) delete ptr;
}
// ***************************************************************************
uint32 CBigFile::CThreadFileArray::allocate()
{
@ -186,11 +194,24 @@ void CBigFile::remove (const std::string &sBigFileName)
fclose (handle.File);
handle.File= NULL;
}
delete [] rbnp.FileNames;
_BNPs.erase (it);
}
}
CBigFile::BNP::BNP() : FileNames(NULL), ThreadFileId(0), CacheFileOnOpen(false), AlwaysOpened(false), InternalUse(false), OffsetFromBeginning(0)
{
}
CBigFile::BNP::~BNP()
{
if (FileNames)
{
delete[] FileNames;
FileNames = NULL;
}
}
//// ***************************************************************************
bool CBigFile::BNP::readHeader()
{