mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-22 14:56:13 +00:00
Fixed: Memory leaks in CBigFile
This commit is contained in:
parent
e9328811af
commit
ec0222958f
2 changed files with 26 additions and 3 deletions
|
@ -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();
|
||||
|
|
|
@ -47,6 +47,14 @@ CBigFile::CThreadFileArray::CThreadFileArray()
|
|||
{
|
||||
_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()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue