From 2e9542c796f01aabf875cae81991a974eb707977 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Sat, 21 Oct 2023 18:40:35 +0200 Subject: [PATCH] switched PRgeHandler where possible to smart pointers. --- src/classes/PRgeHandler.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/classes/PRgeHandler.cpp b/src/classes/PRgeHandler.cpp index fbfe4ac9..74c4d75c 100644 --- a/src/classes/PRgeHandler.cpp +++ b/src/classes/PRgeHandler.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -345,7 +346,7 @@ PRgeHandler::PRgeHandler(const std::string fln) } // create the rge xml handler - PXmlRgeHandler *xmlRge = new PXmlRgeHandler(); + std::unique_ptr xmlRge = std::make_unique(); if (xmlRge == nullptr) { std::cerr << std::endl; std::cerr << "**ERROR** couldn't invoke PXmlRgeHandler." << std::endl; @@ -355,7 +356,7 @@ PRgeHandler::PRgeHandler(const std::string fln) } // create the SAX parser - TSAXParser *saxParser = new TSAXParser(); + std::unique_ptr saxParser = std::make_unique(); if (saxParser == nullptr) { std::cerr << std::endl; std::cerr << "**ERROR** couldn't invoke TSAXParser." << std::endl; @@ -366,7 +367,7 @@ PRgeHandler::PRgeHandler(const std::string fln) saxParser->SetStopOnError(); // connect SAX parser and rge handler - saxParser->ConnectToHandler("PXmlRgeHandler", xmlRge); + saxParser->ConnectToHandler("PXmlRgeHandler", xmlRge.get()); int status = saxParser->ParseFile(fln.c_str()); if (status != 0) { std::cerr << std::endl; @@ -433,9 +434,6 @@ PRgeHandler::PRgeHandler(const std::string fln) fData.push_back(dataSet); } } - - delete saxParser; - delete xmlRge; } //--------------------------------------------------------------------------