From: regrain Date: Tue, 25 Oct 2005 09:22:13 +0000 (+0000) Subject: * Remove memory leaks X-Git-Tag: OpenJPEG.Version1.2~182 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=bf254f32ff1391a5da3ccc13b0aaba4446ee60a6;p=gdcm.git * Remove memory leaks -- BeNours --- diff --git a/Testing/TestBuildUpDicomDir.cxx b/Testing/TestBuildUpDicomDir.cxx index 1aa9cb6f..0c4813c3 100644 --- a/Testing/TestBuildUpDicomDir.cxx +++ b/Testing/TestBuildUpDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestBuildUpDicomDir.cxx,v $ Language: C++ - Date: $Date: 2005/10/19 13:15:36 $ - Version: $Revision: 1.6 $ + Date: $Date: 2005/10/25 09:22:13 $ + Version: $Revision: 1.7 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -40,6 +40,7 @@ int TestBuildUpDicomDir(int argc, char *argv[]) std::cerr << "Usage: " << argv[0] << " dummy " << std::endl; } + bool errorFound = false; gdcm::DicomDir *dcmdir; std::string dirName; @@ -215,7 +216,6 @@ int TestBuildUpDicomDir(int argc, char *argv[]) << "----------Final Check ---------------------" <(entry) ) break; - RemoveEntry(entry); MetaElems->AddEntry(entry); + RemoveEntry(entry); entry = GetFirstEntry(); } @@ -1093,8 +1093,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type, tmpEl = it->Elem; dictEntry = GetPubDict()->GetEntry(tmpGr, tmpEl); - entry = DataEntry::New( dictEntry ); // Be sure it's never a DataEntry ! - + entry = DataEntry::New( dictEntry ); entry->SetOffset(0); // just to avoid further missprinting if ( header ) diff --git a/src/gdcmDicomDirObject.cxx b/src/gdcmDicomDirObject.cxx index b287b7f7..1625584c 100644 --- a/src/gdcmDicomDirObject.cxx +++ b/src/gdcmDicomDirObject.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirObject.cxx,v $ Language: C++ - Date: $Date: 2005/10/24 16:00:47 $ - Version: $Revision: 1.22 $ + Date: $Date: 2005/10/25 09:22:15 $ + Version: $Revision: 1.23 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -73,8 +73,8 @@ void DicomDirObject::FillObject(ListDicomDirMetaElem const &elemList) AddEntry(entry); entry->Delete(); - } -} + } +} //----------------------------------------------------------------------------- // Private diff --git a/src/gdcmDocEntrySet.cxx b/src/gdcmDocEntrySet.cxx index cc91b75f..500dadf5 100644 --- a/src/gdcmDocEntrySet.cxx +++ b/src/gdcmDocEntrySet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntrySet.cxx,v $ Language: C++ - Date: $Date: 2005/10/24 16:00:47 $ - Version: $Revision: 1.65 $ + Date: $Date: 2005/10/25 09:22:15 $ + Version: $Revision: 1.66 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -286,10 +286,10 @@ DataEntry *DocEntrySet::InsertEntryString(std::string const &value, if ( !AddEntry(dataEntry) ) { gdcmWarningMacro("AddEntry failed although this is a creation."); - dataEntry->Delete(); return NULL; } + dataEntry->Delete(); } // Set the dataEntry value @@ -345,10 +345,10 @@ DataEntry *DocEntrySet::InsertEntryBinArea(uint8_t *binArea, int lgth, if ( !AddEntry(dataEntry) ) { gdcmWarningMacro( "AddEntry failed although this is a creation."); - dataEntry->Delete(); return NULL; } + dataEntry->Delete(); } // Set the dataEntry value @@ -414,10 +414,10 @@ SeqEntry *DocEntrySet::InsertSeqEntry(uint16_t group, uint16_t elem) if ( !AddEntry(seqEntry) ) { gdcmWarningMacro( "AddEntry failed although this is a creation."); - seqEntry->Delete(); return NULL; } + seqEntry->Delete(); } // TODO : Find a trick to insert a SequenceDelimitationItem diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index 665604a2..d975fd54 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.cxx,v $ Language: C++ - Date: $Date: 2005/10/24 16:00:47 $ - Version: $Revision: 1.304 $ + Date: $Date: 2005/10/25 09:22:15 $ + Version: $Revision: 1.305 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -1025,6 +1025,7 @@ void Document::ParseDES(DocEntrySet *set, long offset, } else { + newDataEntry->Delete(); // Load only if we can add (not a duplicate key) LoadDocEntry( newDataEntry ); } @@ -1144,12 +1145,16 @@ void Document::ParseDES(DocEntrySet *set, long offset, << newSeqEntry->GetOffset() << " )" ); used = false; } + else + { + newDocEntry->Delete(); + } if ( !delim_mode && ((long)(Fp->tellg())-offset) >= l_max) { if ( !used ) newDocEntry->Delete(); - break; + break; } } // end SeqEntry : VR = "SQ" @@ -1189,6 +1194,7 @@ void Document::ParseSQ( SeqEntry *seqEntry, if ( newDocEntry->IsSequenceDelimitor() ) { seqEntry->SetDelimitationItem( newDocEntry ); + newDocEntry->Delete(); break; } } @@ -1212,7 +1218,6 @@ void Document::ParseSQ( SeqEntry *seqEntry, // Let's try :------------ // remove fff0,e000, created out of the SQItem - newDocEntry->Delete(); Fp->seekg(offsetStartCurrentSQItem, std::ios::beg); // fill up the current SQItem, starting at the beginning of fff0,e000 @@ -1222,6 +1227,7 @@ void Document::ParseSQ( SeqEntry *seqEntry, // end try ----------------- seqEntry->AddSQItem( itemSQ, SQItemNumber ); + newDocEntry->Delete(); SQItemNumber++; if ( !delim_mode && ((long)(Fp->tellg())-offset ) >= l_max ) { diff --git a/src/gdcmFileHelper.cxx b/src/gdcmFileHelper.cxx index 3559242a..f3494a16 100644 --- a/src/gdcmFileHelper.cxx +++ b/src/gdcmFileHelper.cxx @@ -4,8 +4,8 @@ Module: $RCSfile: gdcmFileHelper.cxx,v $ Language: C++ - Date: $Date: 2005/10/24 21:54:28 $ - Version: $Revision: 1.71 $ + Date: $Date: 2005/10/25 09:22:16 $ + Version: $Revision: 1.72 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -1231,6 +1231,7 @@ void FileHelper::CheckMandatoryElements() false); e_0002_0001->SetLength(2); Archive->Push(e_0002_0001); + e_0002_0001->Delete(); // Potentialy post-processed image --> [Secondary Capture Image Storage] // 'Media Storage SOP Class UID'