From 293d2d2aa6e00b2895448ad6f875446391d759f8 Mon Sep 17 00:00:00 2001 From: Giovanni Bussi <giovanni.bussi@gmail.com> Date: Wed, 11 Oct 2017 22:43:11 +0200 Subject: [PATCH] unique_ptr: removed delete --- src/multicolvar/VolumeBetweenContours.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/multicolvar/VolumeBetweenContours.cpp b/src/multicolvar/VolumeBetweenContours.cpp index 737c77ffc..d1e1bfcd0 100644 --- a/src/multicolvar/VolumeBetweenContours.cpp +++ b/src/multicolvar/VolumeBetweenContours.cpp @@ -24,6 +24,7 @@ #include "tools/KernelFunctions.h" #include "tools/SwitchingFunction.h" #include "ActionVolume.h" +#include <memory> //+PLUMEDOC VOLUMES INENVELOPE /* @@ -63,7 +64,7 @@ namespace multicolvar { class VolumeInEnvelope : public ActionVolume { private: LinkCells mylinks; - KernelFunctions* kernel; + std::unique_ptr<KernelFunctions> kernel; std::vector<Value*> pos; std::vector<Vector> ltmp_pos; std::vector<unsigned> ltmp_ind; @@ -104,7 +105,7 @@ VolumeInEnvelope::VolumeInEnvelope(const ActionOptions& ao): std::vector<double> pp(3,0.0), bandwidth(3); parseVector("BANDWIDTH",bandwidth); log.printf(" using %s kernel with bandwidths %f %f %f \n",getKernelType().c_str(),bandwidth[0],bandwidth[1],bandwidth[2] ); - kernel = new KernelFunctions( pp, bandwidth, getKernelType(), "DIAGONAL", 1.0 ); + kernel.reset( new KernelFunctions( pp, bandwidth, getKernelType(), "DIAGONAL", 1.0 ) ); for(unsigned i=0; i<3; ++i) { pos.push_back(new Value()); pos[i]->setNotPeriodic(); } std::vector<double> csupport( kernel->getContinuousSupport() ); double maxs = csupport[0]; @@ -115,7 +116,7 @@ VolumeInEnvelope::VolumeInEnvelope(const ActionOptions& ao): } VolumeInEnvelope::~VolumeInEnvelope() { - delete kernel; for(unsigned j=0; j<3; ++j) delete pos[j]; + for(unsigned j=0; j<3; ++j) delete pos[j]; } void VolumeInEnvelope::setupRegions() { -- GitLab