Skip to content

Commit

Permalink
Re #7876. Use vectors instead of arrays to avoid leaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
RussellTaylor committed Sep 4, 2013
1 parent 332cf05 commit b5e74fd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ namespace MDAlgorithms
~BinMD();

/// Algorithm's name for identification
virtual const std::string name() const { return "BinMD";};
virtual const std::string name() const { return "BinMD";}
/// Algorithm's version for identification
virtual int version() const { return 1;};
virtual int version() const { return 1;}
/// Algorithm's category for identification
virtual const std::string category() const { return "MDAlgorithms";}

Expand All @@ -68,7 +68,7 @@ namespace MDAlgorithms

/// Method to bin a single MDBox
template<typename MDE, size_t nd>
void binMDBox(MDEvents::MDBox<MDE, nd> * box, size_t * chunkMin, size_t * chunkMax);
void binMDBox(MDEvents::MDBox<MDE, nd> * box, const size_t * const chunkMin, const size_t * const chunkMax);


/// The output MDHistoWorkspace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ namespace MDAlgorithms
void makeAlignedDimensionFromString(const std::string & str);
void makeBasisVectorFromString(const std::string & str);

Mantid::Geometry::MDImplicitFunction * getImplicitFunctionForChunk(size_t * chunkMin, size_t * chunkMax);
Mantid::Geometry::MDImplicitFunction * getGeneralImplicitFunction(size_t * chunkMin, size_t * chunkMax);
Mantid::Geometry::MDImplicitFunction * getImplicitFunctionForChunk(const size_t * const chunkMin, const size_t * const chunkMax);
Mantid::Geometry::MDImplicitFunction * getGeneralImplicitFunction(const size_t * const chunkMin, const size_t * const chunkMax);

/// Input workspace
Mantid::API::IMDWorkspace_sptr m_inWS;
Expand Down
10 changes: 5 additions & 5 deletions Code/Mantid/Framework/MDAlgorithms/src/BinMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ namespace MDAlgorithms
* @param chunkMax :: the maximum index in each dimension to consider "valid" (exclusive)
*/
template<typename MDE, size_t nd>
inline void BinMD::binMDBox(MDBox<MDE, nd> * box, size_t * chunkMin, size_t * chunkMax)
inline void BinMD::binMDBox(MDBox<MDE, nd> * box, const size_t * const chunkMin, const size_t * const chunkMax)
{
// An array to hold the rotated/transformed coordinates
coord_t * outCenter = new coord_t[m_outD];
Expand Down Expand Up @@ -374,8 +374,8 @@ namespace MDAlgorithms
{
PARALLEL_START_INTERUPT_REGION
// Region of interest for this chunk.
size_t * chunkMin = new size_t[m_outD];
size_t * chunkMax = new size_t[m_outD];
std::vector<size_t> chunkMin(m_outD);
std::vector<size_t> chunkMax(m_outD);
for (size_t bd=0; bd<m_outD; bd++)
{
// Same limits in the other dimensions
Expand All @@ -390,7 +390,7 @@ namespace MDAlgorithms
chunkMax[chunkDimension] = size_t(chunk+chunkNumBins);

// Build an implicit function (it needs to be in the space of the MDEventWorkspace)
MDImplicitFunction * function = this->getImplicitFunctionForChunk(chunkMin, chunkMax);
MDImplicitFunction * function = this->getImplicitFunctionForChunk(chunkMin.data(), chunkMax.data());

// Use getBoxes() to get an array with a pointer to each box
std::vector<API::IMDNode *> boxes;
Expand Down Expand Up @@ -418,7 +418,7 @@ namespace MDAlgorithms
MDBox<MDE,nd> * box = dynamic_cast<MDBox<MDE,nd> *>(boxes[i]);
// Perform the binning in this separate method.
if (box)
this->binMDBox(box, chunkMin, chunkMax);
this->binMDBox(box, chunkMin.data(), chunkMax.data());

// Progress reporting
if (prog) prog->report();
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/MDAlgorithms/src/SlicingAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ namespace MDAlgorithms
* NULL to use the entire range.
* @return MDImplicitFunction created
*/
MDImplicitFunction * SlicingAlgorithm::getGeneralImplicitFunction(size_t * chunkMin, size_t * chunkMax)
MDImplicitFunction * SlicingAlgorithm::getGeneralImplicitFunction(const size_t * const chunkMin, const size_t * const chunkMax)
{
size_t nd = m_inWS->getNumDims();

Expand Down Expand Up @@ -914,7 +914,7 @@ namespace MDAlgorithms
* NULL to use the entire range.
* @return MDImplicitFunction created
*/
MDImplicitFunction * SlicingAlgorithm::getImplicitFunctionForChunk(size_t * chunkMin, size_t * chunkMax)
MDImplicitFunction * SlicingAlgorithm::getImplicitFunctionForChunk(const size_t * const chunkMin, const size_t * const chunkMax)
{
size_t nd = m_inWS->getNumDims();
if (m_axisAligned)
Expand Down

0 comments on commit b5e74fd

Please sign in to comment.