Skip to content

Commit

Permalink
STYLE: Declare BlockMatchingImageFilter data members as unique_ptr<T[]>
Browse files Browse the repository at this point in the history
  • Loading branch information
N-Dekker authored and hjmjohnson committed Oct 12, 2022
1 parent d666520 commit 64a5cd8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "itkVector.h"
#include "itkDefaultDynamicMeshTraits.h"

#include <memory> // For unique_ptr.

namespace itk
{
Expand Down Expand Up @@ -216,9 +217,9 @@ class ITK_TEMPLATE_EXPORT BlockMatchingImageFilter : public MeshToMeshFilter<TFe
ImageSizeType m_SearchRadius;

// temporary dynamic arrays for storing threads outputs
SizeValueType m_PointsCount;
DisplacementsVector * m_DisplacementsVectorsArray;
SimilaritiesValue * m_SimilaritiesValuesArray;
SizeValueType m_PointsCount;
std::unique_ptr<DisplacementsVector[]> m_DisplacementsVectorsArray;
std::unique_ptr<SimilaritiesValue[]> m_SimilaritiesValuesArray;
};
} // end namespace itk

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "itkConstNeighborhoodIterator.h"
#include <limits>
#include "itkMultiThreaderBase.h"
#include "itkMakeUniqueForOverwrite.h"


namespace itk
Expand Down Expand Up @@ -168,8 +169,8 @@ BlockMatchingImageFilter<TFixedImage, TMovingImage, TFeatures, TDisplacements, T
itkExceptionMacro("Invalid number of feature points: " << this->m_PointsCount << ".");
}

this->m_DisplacementsVectorsArray = new DisplacementsVector[this->m_PointsCount];
this->m_SimilaritiesValuesArray = new SimilaritiesValue[this->m_PointsCount];
this->m_DisplacementsVectorsArray = make_unique_for_overwrite<DisplacementsVector[]>(this->m_PointsCount);
this->m_SimilaritiesValuesArray = make_unique_for_overwrite<SimilaritiesValue[]>(this->m_PointsCount);
}

template <typename TFixedImage,
Expand Down Expand Up @@ -223,8 +224,8 @@ BlockMatchingImageFilter<TFixedImage, TMovingImage, TFeatures, TDisplacements, T
}

// clean up
delete[] m_DisplacementsVectorsArray;
delete[] m_SimilaritiesValuesArray;
m_DisplacementsVectorsArray.reset();
m_SimilaritiesValuesArray.reset();
}

// Callback routine used by the threading library. This routine just calls
Expand Down

0 comments on commit 64a5cd8

Please sign in to comment.