Skip to content
Snippets Groups Projects
Commit 52ccaa11 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

DerivationFrameworkTools: use unique_ptr to avoid memory leak (cppcheck)

parent 3fb15d0b
No related branches found
No related tags found
No related merge requests found
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
......@@ -9,6 +9,7 @@
#ifndef DERIVATIONFRAMEWORK_NTUPSTRINGSKIMMINGTOOL_H
#define DERIVATIONFRAMEWORK_NTUPSTRINGSKIMMINGTOOL_H
#include <memory>
#include <string>
#include "AthenaBaseComps/AthAlgTool.h"
......@@ -24,13 +25,12 @@ namespace DerivationFramework {
public:
NTUPStringSkimmingTool(const std::string& t, const std::string& n, const IInterface* p);
StatusCode initialize();
StatusCode finalize();
virtual bool eventPassesFilter() const;
virtual StatusCode initialize() override;
virtual bool eventPassesFilter() const override;
private:
std::string m_expression;
ExpressionParsing::ExpressionParser *m_parser;
std::unique_ptr<ExpressionParsing::ExpressionParser> m_parser;
};
}
......
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
*/
/////////////////////////////////////////////////////////////////
......@@ -24,8 +24,7 @@ namespace DerivationFramework {
const std::string& n,
const IInterface* p) :
AthAlgTool(t,n,p),
m_expression("true"),
m_parser(nullptr)
m_expression("true")
{
declareInterface<DerivationFramework::ISkimmingTool>(this);
declareProperty("expression", m_expression);
......@@ -33,20 +32,11 @@ namespace DerivationFramework {
StatusCode NTUPStringSkimmingTool::initialize()
{
m_parser = new ExpressionParsing::ExpressionParser(new ExpressionParsing::SGNTUPProxyLoader(evtStore()));
m_parser = std::make_unique<ExpressionParsing::ExpressionParser>(new ExpressionParsing::SGNTUPProxyLoader(evtStore()));
m_parser->loadExpression(m_expression);
return StatusCode::SUCCESS;
}
StatusCode NTUPStringSkimmingTool::finalize()
{
if (m_parser) {
delete m_parser;
m_parser = nullptr;
}
return StatusCode::SUCCESS;
}
bool NTUPStringSkimmingTool::eventPassesFilter() const
{
return m_parser->evaluateAsBool();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment