]> Creatis software - gdcm.git/commitdiff
* Remove memory leaks
authorregrain <regrain>
Tue, 25 Oct 2005 09:22:13 +0000 (09:22 +0000)
committerregrain <regrain>
Tue, 25 Oct 2005 09:22:13 +0000 (09:22 +0000)
   -- BeNours

Testing/TestBuildUpDicomDir.cxx
src/gdcmDicomDir.cxx
src/gdcmDicomDirObject.cxx
src/gdcmDocEntrySet.cxx
src/gdcmDocument.cxx
src/gdcmFileHelper.cxx

index 1aa9cb6fcf95cc0873c0a785bd55a13bf68e8d97..0c4813c30efdf67f77bfb41e94580128704bccf0 100644 (file)
@@ -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 ---------------------" 
              <<std::endl;
  
-   bool errorFound = false; 
    std::string valueStuff;  
    for (;;) // exit on 'break'
    {
@@ -357,14 +357,13 @@ int TestBuildUpDicomDir(int argc, char *argv[])
       break; // No error found. Stop looping
    }
 
-   delete newDicomDir;
    if ( errorFound )
    {
       std::cout << "MissWritting / MissReading " << std::endl;
-      std::cout<<std::flush;
-      return(1);
    }
 
    std::cout<<std::flush;
-   return 0;
+   delete newDicomDir;
+
+   return errorFound;
 }
index f002e6f7ca0f174888cb41ba9c165f2ec073916d..17da13ee9e5aebf45bb5bc7c44590a3e3c163607 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/24 16:00:47 $
-  Version:   $Revision: 1.165 $
+  Date:      $Date: 2005/10/25 09:22:15 $
+  Version:   $Revision: 1.166 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -319,8 +319,8 @@ DicomDirMeta *DicomDir::NewMeta()
          if ( dynamic_cast<SeqEntry *>(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 )
index b287b7f7a62f06357126de346d8b675d780dabda..1625584cb2670c6542cd653c781ead5035d3137b 100644 (file)
@@ -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
index cc91b75fd8ce796120041c6886c125405292e2d8..500dadf5c484c7fc24abfdc69f9041e04323adf6 100644 (file)
@@ -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 
index 665604a2996f5f997ac008d2cfdf8e8b4db89cca..d975fd54d4c2dcd30375f0153c1641eff50ffd51 100644 (file)
@@ -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 )
       {
index 3559242a967dcfb657341d16e252a9b89431fa45..f3494a16276825c49f6f82be033aba95b2f7ae8e 100644 (file)
@@ -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'