]> Creatis software - gdcm.git/commitdiff
* FIX: src/gdcmUtil.cxx : to compile with MSVC6
authorregrain <regrain>
Tue, 16 Nov 2004 10:37:54 +0000 (10:37 +0000)
committerregrain <regrain>
Tue, 16 Nov 2004 10:37:54 +0000 (10:37 +0000)
   * src/gdcmDocument.cxx : fix memory leaks. Fix possible bugs : use an object
     after it have been deleted
   -- BeNours

ChangeLog
src/gdcmDocument.cxx
src/gdcmElementSet.cxx
src/gdcmUtil.cxx

index 79b17c7da079d90173930046521d27a7ea3f03a2..dd35885f3b4540e892453031c4fe7859ccde7180 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-11-15 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
+   * FIX: src/gdcmUtil.cxx : to compile with MSVC6
+   * src/gdcmDocument.cxx : fix memory leaks. Fix possible bugs : use an object
+     after it have been deleted
+
 2004-11-09 Eric Boix <Eric.Boix@creatis.insa-lyon.fr>
    * FIX: src/* fix the doxygen warnings.
 
index 2fbb8bd7884047ffeea053322bebef07c1510fc7..50e9dd4586e08da0556d873904b470458ddd391b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/16 10:25:53 $
-  Version:   $Revision: 1.125 $
+  Date:      $Date: 2004/11/16 10:37:54 $
+  Version:   $Revision: 1.126 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -576,16 +576,17 @@ ValEntry* Document::ReplaceOrCreateByNumber(
                         " NewDocEntryByNumber failed.");
          return NULL;
       }
+
       valEntry = new ValEntry(currentEntry);
+      delete currentEntry;
+
       if ( !AddEntry(valEntry))
       {
          delete valEntry;
          dbg.Verbose(0, "Document::ReplaceOrCreateByNumber: AddEntry"
                         " failed allthough this is a creation.");
+         return NULL;
       }
-      // This is the reason why NewDocEntryByNumber are a real
-      // bad habit !!! FIXME
-      delete currentEntry;
    }
    else
    {
@@ -1362,13 +1363,15 @@ void Document::ParseDES(DocEntrySet *set, long offset,
                                    + newValEntry->GetKey() );
             }
              
+            LoadDocEntry( newValEntry );
+            bool delimitor=newValEntry->IsItemDelimitor();
             if( !set->AddEntry( newValEntry ) )
             {
               // If here expect big troubles
               delete newValEntry; //otherwise mem leak
             }
-            LoadDocEntry( newValEntry );
-            if (newValEntry->IsItemDelimitor())
+
+            if (delimitor)
             {
                break;
             }
@@ -1387,9 +1390,10 @@ void Document::ParseDES(DocEntrySet *set, long offset,
             }
 
          //////////////////// BinEntry or UNKOWN VR:
-            BinEntry* newBinEntry =
+/*            BinEntry* newBinEntry =
                new BinEntry( newDocEntry->GetDictEntry() );  //LEAK
-            newBinEntry->Copy( newDocEntry );
+            newBinEntry->Copy( newDocEntry );*/
+            BinEntry* newBinEntry = new BinEntry( newDocEntry );  //LEAK
 
             // When "this" is a Document the Key is simply of the
             // form ( group, elem )...
@@ -1407,12 +1411,12 @@ void Document::ParseDES(DocEntrySet *set, long offset,
                                    + newBinEntry->GetKey() );
             }
 
+            LoadDocEntry( newBinEntry );
             if( !set->AddEntry( newBinEntry ) )
             {
               //Expect big troubles if here
               delete newBinEntry;
             }
-            LoadDocEntry( newBinEntry );
          }
 
          if (    ( newDocEntry->GetGroup()   == 0x7fe0 )
index 22f4ed98d1c9470fa4112804635526f5535893a1..37340268a3fe5510c328290063ee13f2c59d83b8 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmElementSet.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/16 02:54:35 $
-  Version:   $Revision: 1.27 $
+  Date:      $Date: 2004/11/16 10:37:54 $
+  Version:   $Revision: 1.28 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -118,12 +118,12 @@ bool ElementSet::AddEntry(DocEntry* newEntry)
       dbg.Verbose(1, "ElementSet::AddEntry key already present: ",
                   key.c_str());
       return false;
-   } 
-   else 
+   }
+   else
    {
       TagHT.insert(TagDocEntryHT::value_type(newEntry->GetKey(), newEntry));
       return true;
-   }   
+   }
 }
 
 /**
index 509b6984604b3d26b73b63d7bc0c7eb9bf99af8a..edaee708673a42246819c89f80ecad4069a6ec0a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmUtil.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/16 10:25:53 $
-  Version:   $Revision: 1.65 $
+  Date:      $Date: 2004/11/16 10:37:54 $
+  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
 #include <stdarg.h>  //only included in implementation file
 #include <stdio.h>   //only included in implementation file
 
-#include <unistd.h>  // for gethostname
-#include <netdb.h>   // for gethostbyname
+#if defined _MSC_VER || defined(__BORLANDC__)
+   #include <winsock.h>  // for gethostname & gethostbyname
+   #undef GetCurrentTime
+#else
+   #include <unistd.h>  // for gethostname
+   #include <netdb.h>   // for gethostbyname
+#endif
 
 namespace gdcm 
 {
-
 /**
  * \ingroup Globals
  * \brief Provide a better 'c++' approach for sprintf