From 24717a81bf7bec3aa5a1a8dfda56718f0de8b917 Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Thu, 28 May 2020 14:05:58 +0200
Subject: [PATCH] [A/IO] Subst. manual removing by cleanupVectorElements.

---
 Applications/FileIO/GMSInterface.cpp    | 9 +--------
 Applications/FileIO/TetGenInterface.cpp | 9 +--------
 2 files changed, 2 insertions(+), 16 deletions(-)

diff --git a/Applications/FileIO/GMSInterface.cpp b/Applications/FileIO/GMSInterface.cpp
index 71cab4a8c2e..10415bddc5f 100644
--- a/Applications/FileIO/GMSInterface.cpp
+++ b/Applications/FileIO/GMSInterface.cpp
@@ -304,14 +304,7 @@ MeshLib::Mesh* GMSInterface::readGMS3DMMesh(const std::string& filename)
         if (!opt_pv)
         {
             ERR("Could not create PropertyVector for material ids.");
-            for (auto element : elements)
-            {
-                delete element;
-            }
-            for (auto node : nodes)
-            {
-                delete node;
-            }
+            BaseLib::cleanupVectorElements(nodes, elements);
             return nullptr;
         }
         opt_pv->reserve(mat_ids.size());
diff --git a/Applications/FileIO/TetGenInterface.cpp b/Applications/FileIO/TetGenInterface.cpp
index 1548468abc6..5e9afac09ba 100644
--- a/Applications/FileIO/TetGenInterface.cpp
+++ b/Applications/FileIO/TetGenInterface.cpp
@@ -239,14 +239,7 @@ MeshLib::Mesh* TetGenInterface::readTetGenMesh (std::string const& nodes_fname,
     std::vector<MeshLib::Element*> elements;
     std::vector<int> materials;
     if (!readElementsFromStream (ins_ele, elements, materials, nodes)) {
-        // remove elements read until now
-        for (auto & element : elements) {
-            delete element;
-        }
-        // remove nodes
-        for (auto & node : nodes) {
-            delete node;
-        }
+        BaseLib::cleanupVectorElements(nodes, elements);
         return nullptr;
     }
 
-- 
GitLab