diff OrthancServer/Sources/Database/FindResponse.cpp @ 5673:ebcbb448bea8 find-refactoring

improved memory
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 06 Jul 2024 14:31:22 +0200
parents e300f22a46f0
children 74f3aab95886
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/FindResponse.cpp	Sat Jul 06 14:24:45 2024 +0200
+++ b/OrthancServer/Sources/Database/FindResponse.cpp	Sat Jul 06 14:31:22 2024 +0200
@@ -142,6 +142,22 @@
   }
 
 
+  FindResponse::ChildrenInformation::~ChildrenInformation()
+  {
+    for (MetadataValues::iterator it = metadataValues_.begin(); it != metadataValues_.end(); ++it)
+    {
+      assert(it->second != NULL);
+      delete it->second;
+    }
+
+    for (MainDicomTagValues::iterator it = mainDicomTagValues_.begin(); it != mainDicomTagValues_.end(); ++it)
+    {
+      assert(it->second != NULL);
+      delete it->second;
+    }
+  }
+
+
   void FindResponse::ChildrenInformation::AddIdentifier(const std::string& identifier)
   {
     if (identifiers_.find(identifier) == identifiers_.end())
@@ -164,11 +180,12 @@
     {
       std::set<std::string> s;
       s.insert(value);
-      metadataValues_[metadata] = s;
+      metadataValues_[metadata] = new std::set(s);
     }
     else
     {
-      found->second.insert(value);
+      assert(found->second != NULL);
+      found->second->insert(value);
     }
   }
 
@@ -184,7 +201,8 @@
     }
     else
     {
-      values = found->second;
+      assert(found->second != NULL);
+      values = *found->second;
     }
   }
 
@@ -198,11 +216,12 @@
     {
       std::set<std::string> s;
       s.insert(value);
-      mainDicomTagValues_[tag] = s;
+      mainDicomTagValues_[tag] = new std::set(s);
     }
     else
     {
-      found->second.insert(value);
+      assert(found->second != NULL);
+      found->second->insert(value);
     }
   }
 
@@ -218,7 +237,8 @@
     }
     else
     {
-      values = found->second;
+      assert(found->second != NULL);
+      values = *found->second;
     }
   }