Commit dcf2538e authored by Scott Snyder's avatar Scott Snyder Committed by Graeme Stewart
Browse files

'Fix potential memory leaks.' (TestLArHardwareID-00-03-41)

	* Tagging TestLArHardwareID-00-03-41.
	* cppcheck warnings: Fix potential memory leaks.
parent e6b2902a
################################################################################
# Package: TestLArHardwareID
################################################################################
# Declare the package name:
atlas_subdir( TestLArHardwareID )
# Declare the package's dependencies:
atlas_depends_on_subdirs( PUBLIC
Control/AthenaBaseComps
Database/RegistrationServices
GaudiKernel
PRIVATE
Control/CxxUtils
Calorimeter/CaloIdentifier
Calorimeter/CaloTriggerTool
Control/AthenaKernel
Control/StoreGate
LArCalorimeter/LArCabling
LArCalorimeter/LArIdentifier
Tools/PathResolver )
# Component(s) in the package:
atlas_add_component( TestLArHardwareID
src/*.cxx
src/components/*.cxx
LINK_LIBRARIES CxxUtils AthenaBaseComps GaudiKernel CaloIdentifier CaloTriggerToolLib AthenaKernel StoreGateLib SGtests LArCablingLib LArIdentifier PathResolver )
# Install files from the package:
atlas_install_headers( TestLArHardwareID )
atlas_install_joboptions( share/*.py )
atlas_install_runtime( share/FCal-online-map.txt )
......@@ -12,6 +12,7 @@ use RegistrationServices RegistrationServices-* Database
use AthenaBaseComps AthenaBaseComps-* Control
private
use CxxUtils CxxUtils-* Control
use StoreGate StoreGate-* Control
use AthenaKernel AthenaKernel-* Control
use PathResolver PathResolver-* Tools
......
......@@ -27,6 +27,7 @@
#include "CaloTriggerTool/CaloTriggerTowerService.h"
#include "CaloTriggerTool/LArTTCell.h"
#include "CaloTriggerTool/LArTTCellMap.h"
#include "CxxUtils/make_unique.h"
/********************************************************/
initTTMap_Algo::initTTMap_Algo(const std::string &name , ISvcLocator* pSvcLocator) :
......@@ -363,17 +364,17 @@ StatusCode initTTMap_Algo::testStruct(){
ATH_MSG_DEBUG(" Dump of LArTTCellMap" );
ATH_MSG_DEBUG(" Persistent LArTTCell_P version = "<<ttCell_P->m_version);
int lines=0;
std::ofstream* dumpFcal=0;
std::ofstream* dumpOther=0;
std::unique_ptr<std::ofstream> dumpFcal;
std::unique_ptr<std::ofstream> dumpOther;
std::string fcalFile="initDumpFCAL.txt";
std::string otherFile="initDumpOther.txt";
if(m_dumpMap) {
dumpFcal=new std::ofstream(fcalFile.c_str());
dumpFcal=CxxUtils::make_unique<std::ofstream>(fcalFile.c_str());
if (dumpFcal==0) {
std::cout << "Problem opening FCAL dump file" << std::endl;
return 1;
}
dumpOther=new std::ofstream(otherFile.c_str());
dumpOther=CxxUtils::make_unique<std::ofstream>(otherFile.c_str());
if (dumpOther==0) {
std::cout << "Problem opening other dump file" << std::endl;
return 1;
......@@ -436,9 +437,7 @@ StatusCode initTTMap_Algo::testStruct(){
if(m_dumpMap) {
dumpFcal->close();
delete dumpFcal;
dumpOther->close();
delete dumpOther;
}
ATH_MSG_DEBUG(" number of lines found = "<< lines);
......
......@@ -26,6 +26,7 @@
#include "CaloTriggerTool/LArTTCell.h"
#include "CaloTriggerTool/LArTTCellMap.h"
#include "CxxUtils/make_unique.h"
/********************************************************/
reinitTTMap_Algo::reinitTTMap_Algo(const std::string &name , ISvcLocator* pSvcLocator) :
......@@ -322,17 +323,17 @@ StatusCode reinitTTMap_Algo::testStruct(){
ATH_MSG_DEBUG(" Dump of LArTTCellMap" );
ATH_MSG_DEBUG(" Persistent LArTTCell_P version = "<<ttCell_P->m_version);
int lines=0;
std::ofstream* dumpFcal=0;
std::ofstream* dumpOther=0;
std::unique_ptr<std::ofstream> dumpFcal;
std::unique_ptr<std::ofstream> dumpOther;
std::string fcalFile="initDumpFCAL.txt";
std::string otherFile="initDumpOther.txt";
if(m_dumpMap) {
dumpFcal=new std::ofstream(fcalFile.c_str());
dumpFcal=CxxUtils::make_unique<std::ofstream>(fcalFile.c_str());
if (dumpFcal==0) {
std::cout << "Problem opening FCAL dump file" << std::endl;
return 1;
}
dumpOther=new std::ofstream(otherFile.c_str());
dumpOther=CxxUtils::make_unique<std::ofstream>(otherFile.c_str());
if (dumpOther==0) {
std::cout << "Problem opening other dump file" << std::endl;
return 1;
......@@ -395,9 +396,7 @@ StatusCode reinitTTMap_Algo::testStruct(){
if(m_dumpMap) {
dumpFcal->close();
delete dumpFcal;
dumpOther->close();
delete dumpOther;
}
ATH_MSG_DEBUG(" number of lines found = "<< lines);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment