Skip to content

Commit

Permalink
Refs #4011. Fix some obvious memory leaks picked up by cppcheck.
Browse files Browse the repository at this point in the history
  • Loading branch information
martyngigg committed Oct 26, 2011
1 parent 4dc1e09 commit edc416d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Code/Mantid/Framework/CurveFitting/src/Convolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ void Convolution::functionMW(double* out, const double* xValues, const size_t nD
API::IFunctionMW* fun = dynamic_cast<API::IFunctionMW*>(getFunction(0));
if (!fun)
{
delete [] xr;
throw std::runtime_error("Convolution can work only with IFunctionMW");
}
fun->functionMW(m_resolution,xr,nData);
Expand Down Expand Up @@ -193,7 +194,7 @@ void Convolution::functionMW(double* out, const double* xValues, const size_t nD
resolution->functionMW(tmp,xValues,nData);
std::transform(tmp,tmp+nData,tmp,std::bind2nd(std::multiplies<double>(),dltF));
std::transform(out,out+nData,tmp,out,std::plus<double>());
delete tmp;
delete [] tmp;
}

}
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/DataHandling/src/SaveISISNexus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ int SaveISISNexus::saveStringVectorOpen(const char* name,const std::vector<std::
std::copy(str,str + n,buff);
NXputslab(handle,buff,start,sizes);
}
delete buff;
delete [] buff;
return buff_size;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ In addition, this only works for instruments that use [[RectangularDetector]]s (
#include <cmath>
#include <numeric>
#include <boost/shared_ptr.hpp>
#include <boost/scoped_array.hpp>
#include <Poco/File.h>
//#include <hdf5.h> //This is troublesome on multiple platforms.

Expand Down Expand Up @@ -584,8 +585,7 @@ namespace DataHandling
// 1 dimension, with that number of bin boundaries
dataDimensions[0] = static_cast<int>(X.size());
// The output TOF axis will be whatever size in the workspace.
float *tof_data; /* pointer to data buffer to write */
tof_data = new float[dataDimensions[0]];
boost::scoped_array<float> tof_data(new float[dataDimensions[0]]);

// And fill it with the X data
for (size_t i=0; i < X.size(); i++)
Expand All @@ -594,8 +594,7 @@ namespace DataHandling
if (NXcompmakedata (outId, name, dataType, dataRank, dataDimensions, NX_COMP_LZW, dataDimensions) != NX_OK) return NX_ERROR;
if (NXopendata (outId, name) != NX_OK) return NX_ERROR;
if (WriteAttributes (is_definition) != NX_OK) return NX_ERROR;
if (NXputdata (outId, tof_data) != NX_OK) return NX_ERROR;
delete [] tof_data;
if (NXputdata (outId, tof_data.get()) != NX_OK) return NX_ERROR;
if (NXclosedata (outId) != NX_OK) return NX_ERROR;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ namespace VATES
points->Delete();
signal->Delete();
visualDataSet->Squeeze();
delete [] pointIDs;
delete [] voxelShown;
delete [] pointNeeded;
return visualDataSet;

}
Expand Down
4 changes: 4 additions & 0 deletions Code/Mantid/Vates/VatesAPI/src/vtkThresholdingQuadFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ namespace Mantid
points->Delete();
signal->Delete();
visualDataSet->Squeeze();
delete [] pointIDs;
delete [] voxelShown;
delete [] pointNeeded;

return visualDataSet;
}
}
Expand Down

0 comments on commit edc416d

Please sign in to comment.