From: regrain Date: Tue, 16 Nov 2004 10:37:54 +0000 (+0000) Subject: * FIX: src/gdcmUtil.cxx : to compile with MSVC6 X-Git-Tag: Version1.0.bp~596 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=6fc40309997e3c20fc494201644a3e8094f0c971;p=gdcm.git * 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 -- BeNours --- diff --git a/ChangeLog b/ChangeLog index 79b17c7d..dd35885f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-11-15 Benoit Regrain + * 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 * FIX: src/* fix the doxygen warnings. diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index 2fbb8bd7..50e9dd45 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -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 ) diff --git a/src/gdcmElementSet.cxx b/src/gdcmElementSet.cxx index 22f4ed98..37340268 100644 --- a/src/gdcmElementSet.cxx +++ b/src/gdcmElementSet.cxx @@ -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; - } + } } /** diff --git a/src/gdcmUtil.cxx b/src/gdcmUtil.cxx index 509b6984..edaee708 100644 --- a/src/gdcmUtil.cxx +++ b/src/gdcmUtil.cxx @@ -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 @@ -27,12 +27,16 @@ #include //only included in implementation file #include //only included in implementation file -#include // for gethostname -#include // for gethostbyname +#if defined _MSC_VER || defined(__BORLANDC__) + #include // for gethostname & gethostbyname + #undef GetCurrentTime +#else + #include // for gethostname + #include // for gethostbyname +#endif namespace gdcm { - /** * \ingroup Globals * \brief Provide a better 'c++' approach for sprintf