diff --git a/Modules/Nonunit/Review/include/itkAttributeMorphologyBaseImageFilter.h b/Modules/Nonunit/Review/include/itkAttributeMorphologyBaseImageFilter.h index 44e35582390..1e17633f0c8 100644 --- a/Modules/Nonunit/Review/include/itkAttributeMorphologyBaseImageFilter.h +++ b/Modules/Nonunit/Review/include/itkAttributeMorphologyBaseImageFilter.h @@ -20,6 +20,7 @@ #include "itkImageToImageFilter.h" #include +#include // For unique_ptr. namespace itk { @@ -167,7 +168,7 @@ class ITK_TEMPLATE_EXPORT AttributeMorphologyBaseImageFilter : public ImageToIma static constexpr OffsetValueType ACTIVE = -2; // Just used for area/volume openings at the moment - AttributeType * m_AuxData; + std::unique_ptr m_AuxData; using OffsetVecType = std::vector; // offset in the linear array. @@ -180,11 +181,11 @@ class ITK_TEMPLATE_EXPORT AttributeMorphologyBaseImageFilter : public ImageToIma // it is sorted with a stable sort by grey level as the // first step in the algorithm. The sorting step avoids // the need to explicitly locate regional extrema. - OffsetValueType * m_SortPixels; - OffsetValueType * m_Parent; + std::unique_ptr m_SortPixels; + std::unique_ptr m_Parent; // This is a bit ugly, but I can't see an easy way around - InputPixelType * m_Raw; + std::unique_ptr m_Raw; class CompareOffsetType { diff --git a/Modules/Nonunit/Review/include/itkAttributeMorphologyBaseImageFilter.hxx b/Modules/Nonunit/Review/include/itkAttributeMorphologyBaseImageFilter.hxx index 97f95aa9a48..9d414ff80f0 100644 --- a/Modules/Nonunit/Review/include/itkAttributeMorphologyBaseImageFilter.hxx +++ b/Modules/Nonunit/Review/include/itkAttributeMorphologyBaseImageFilter.hxx @@ -24,6 +24,7 @@ #include "itkConnectedComponentAlgorithm.h" #include "itkNeighborhoodAlgorithm.h" #include "itkCastImageFilter.h" +#include "itkMakeUniqueForOverwrite.h" /* * This code was contributed in the Insight Journal paper @@ -97,12 +98,12 @@ AttributeMorphologyBaseImageFilter(buffsize); + m_Parent = make_unique_for_overwrite(buffsize); // This is a bit ugly, but I can't see an easy way around - m_Raw = new InputPixelType[buffsize]; - m_AuxData = new AttributeType[buffsize]; + m_Raw = make_unique_for_overwrite(buffsize); + m_AuxData = make_unique_for_overwrite(buffsize); // copy the pixels to the sort buffer using CRegionIteratorType = ImageRegionConstIteratorWithIndex; @@ -120,7 +121,7 @@ AttributeMorphologyBaseImageFilter diff --git a/Modules/Nonunit/Review/include/itkDirectFourierReconstructionImageToImageFilter.hxx b/Modules/Nonunit/Review/include/itkDirectFourierReconstructionImageToImageFilter.hxx index 8866e61360b..d78df126cb5 100644 --- a/Modules/Nonunit/Review/include/itkDirectFourierReconstructionImageToImageFilter.hxx +++ b/Modules/Nonunit/Review/include/itkDirectFourierReconstructionImageToImageFilter.hxx @@ -18,6 +18,7 @@ #ifndef itkDirectFourierReconstructionImageToImageFilter_hxx #define itkDirectFourierReconstructionImageToImageFilter_hxx +#include "itkMakeUniqueForOverwrite.h" namespace itk { @@ -214,7 +215,7 @@ DirectFourierReconstructionImageToImageFilter::Genera FFT->SetInput(projectionLine); // Setup FFT Line interpolator stack - auto * FFTLineInterpolator = new FFTLineInterpolatorType::Pointer[alpha_size]; + const auto FFTLineInterpolator = make_unique_for_overwrite(alpha_size); for (unsigned int alpha = 0; alpha < alpha_size; ++alpha) { FFTLineInterpolator[alpha] = FFTLineInterpolatorType::New(); @@ -413,8 +414,6 @@ DirectFourierReconstructionImageToImageFilter::Genera inputIt.NextSlice(); } // while ( !inputIt.IsAtEnd() ) - - delete[] FFTLineInterpolator; } } // namespace itk