]> Creatis software - gdcm.git/commitdiff
* Test/TestAllEntryVerify.cxx, makeDicomDir.cxx : fix memory leaks
authorregrain <regrain>
Thu, 27 Jan 2005 10:47:29 +0000 (10:47 +0000)
committerregrain <regrain>
Thu, 27 Jan 2005 10:47:29 +0000 (10:47 +0000)
   -- BeNours

Testing/TestAllEntryVerify.cxx

index 089b4c1b1ed61570203d00112ff5379eb6e149e4..adcf230699a5c32217b448900d6e6902b022af38 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestAllEntryVerify.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/25 15:29:33 $
-  Version:   $Revision: 1.22 $
+  Date:      $Date: 2005/01/27 10:47:29 $
+  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
@@ -52,6 +52,8 @@ class ReferenceFileParser
 {
 public:
    ReferenceFileParser();
+   ~ReferenceFileParser();
+
    bool Open( std::string& referenceFileName );
    void Print();
    void SetDataPath(std::string&);
@@ -75,6 +77,7 @@ private:
    void HandleKey( std::string& line )             throw ( ParserException );
    bool HandleValue( std::string& line )           throw ( ParserException );
    static uint16_t axtoi( char* );
+
 private:
    /// The directory containing the images to check:
    std::string DataPath;
@@ -104,38 +107,57 @@ private:
    MapEntryValues* CurrentMapEntryValuesPtr;
 };
 
+ReferenceFileParser::ReferenceFileParser()
+{
+   lineNumber = 1;
+   Indent = "      ";
+}
+
+ReferenceFileParser::~ReferenceFileParser()
+{
+   for (MapFileValuesType::iterator i  = ProducedMap.begin();
+                                    i != ProducedMap.end();
+                                    ++i)
+   {
+      delete i->second;
+   }
+}
+
 /// As gotten from:
 /// http://community.borland.com/article/0,1410,17203,0.html
-uint16_t ReferenceFileParser::axtoi(char *hexStg) {
-  int n = 0;         // position in string
-  int m = 0;         // position in digit[] to shift
-  int count;         // loop index
-  int intValue = 0;  // integer value of hex string
-  int digit[5];      // hold values to convert
-  while (n < 4) {
-     if (hexStg[n]=='\0')
-        break;
-     if (hexStg[n] > 0x29 && hexStg[n] < 0x40 )    //if 0 to 9
-        digit[n] = hexStg[n] & 0x0f;               //convert to int
-     else if (hexStg[n] >='a' && hexStg[n] <= 'f') //if a to f
-        digit[n] = (hexStg[n] & 0x0f) + 9;         //convert to int
-     else if (hexStg[n] >='A' && hexStg[n] <= 'F') //if A to F
-        digit[n] = (hexStg[n] & 0x0f) + 9;         //convert to int
-     else break;
-    n++;
-  }
-  count = n;
-  m = n - 1;
-  n = 0;
-  while(n < count) {
-     // digit[n] is value of hex digit at position n
-     // (m << 2) is the number of positions to shift
-     // OR the bits into return value
-     intValue = intValue | (digit[n] << (m << 2));
-     m--;   // adjust the position to set
-     n++;   // next digit to process
-  }
-  return intValue;
+uint16_t ReferenceFileParser::axtoi(char *hexStg) 
+{
+   int n = 0;         // position in string
+   int m = 0;         // position in digit[] to shift
+   int count;         // loop index
+   int intValue = 0;  // integer value of hex string
+   int digit[5];      // hold values to convert
+   while (n < 4) 
+   {
+      if (hexStg[n]=='\0')
+         break;
+      if (hexStg[n] > 0x29 && hexStg[n] < 0x40 )    //if 0 to 9
+         digit[n] = hexStg[n] & 0x0f;               //convert to int
+      else if (hexStg[n] >='a' && hexStg[n] <= 'f') //if a to f
+         digit[n] = (hexStg[n] & 0x0f) + 9;         //convert to int
+      else if (hexStg[n] >='A' && hexStg[n] <= 'F') //if A to F
+         digit[n] = (hexStg[n] & 0x0f) + 9;         //convert to int
+      else break;
+     n++;
+   }
+   count = n;
+   m = n - 1;
+   n = 0;
+   while(n < count) 
+   {
+      // digit[n] is value of hex digit at position n
+      // (m << 2) is the number of positions to shift
+      // OR the bits into return value
+      intValue = intValue | (digit[n] << (m << 2));
+      m--;   // adjust the position to set
+      n++;   // next digit to process
+   }
+   return intValue;
 }
 
 void ReferenceFileParser::SetDataPath( std::string& inDataPath )
@@ -455,12 +477,6 @@ void ReferenceFileParser::FirstPassReferenceFile() throw ( ParserException )
    from.seekg( 0, std::ios::beg );
 }
 
-ReferenceFileParser::ReferenceFileParser()
-{
-   lineNumber = 1;
-   Indent = "      ";
-}
-
 bool ReferenceFileParser::Open( std::string& referenceFileName )
 {
    from.open( referenceFileName.c_str(), std::ios::in );