If I run the code below, VS2010 memory leaks detector built in the CRT Debug Library reports leaks. If I explicitly delete all the wxZipEntry pointers I get, the leaks go away, but I fee like it's wrong: in the wxZipOutputStream::Close() method the entries are deleted and the evidence is that if I delete it before tempZipOutput.Close();
the Close method gives an exception because memory can't be read, if I delete the entries with delete(*entry); after tempZipOutput.Close(); the delete( gives same exception in its turn.
Code: Select all
wxFileOutputStream tempZipOut(sFileName);
wxZipOutputStream tempZipOutput(tempZipOut);
wxString sInFileName;
wxString CurrDir = wxGetCwd();
wxFileInputStream zipFileIn(sInFileName);
wxZipInputStream zipIn(zipFileIn);
wxZipEntry **entry, **pBegin;
int iTotEntries = zipIn.GetTotalEntries();
entry = (wxZipEntry**) calloc(iTotEntries, sizeof(wxZipEntry*));
while(*entry=zipIn.GetNextEntry()){
if(iEntriesCount == 0)
pBegin = entry;
iEntriesCount++;
if(*entry!=NULL){
//I do my stuff with the entries
//if(iEntriesCount < iTotEntries){
tempZipOutput.CloseEntry();
//zipIn.CloseEntry();
//delete(entry);
//entry = NULL;
//}
}
entry++;
}
tempZipOutput.Close();
/*
the memory leaks detector built in the CRT Debug Library senses the entries are not deleted in tempZipOutput.Close(); but it's
wrong, actually they are in d:\wxWidgets-2.9.5\src\common\zipstrm.cpp ln. 2320 in the wxZipOutputStream::Close() method.
vld exits without claiming
entry = pBegin;
for(int i=0; i<iTotEntries; i++){
delete(*entry);
entry++;
}
*/
tempZipOut.Close();
Thanks a lot, BR,
Max.