Skip to content

Commit 3c8ff8b

Browse files
N-Dekkerhjmjohnson
authored andcommitted
STYLE: Remove new, do make_unique_for_overwrite in NeighborhoodAllocator
Replaced `new` with `make_unique_for_overwrite` in its copy-constructor. Removed `new` and `delete[]` from its documentation, as suggested by Mihail Isakov. Following C++ Core Guidelines, September 23, 2022, "Avoid calling `new` and `delete` explicitly", from http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rr-newdelete
1 parent 9df8f74 commit 3c8ff8b

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Modules/Core/Common/include/itkNeighborhoodAllocator.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ class NeighborhoodAllocator
6060
/** Defaulted destructor */
6161
~NeighborhoodAllocator() = default;
6262

63-
/** Allocates memory using new() */
63+
/** Allocates memory. */
6464
void
6565
Allocate(unsigned int n)
6666
{
6767
m_Data = make_unique_for_overwrite<TPixel[]>(n);
6868
m_ElementCount = n;
6969
}
7070

71-
/** Deallocates memory using delete[](). */
71+
/** Deallocates memory. */
7272
void
7373
Deallocate()
7474
{
@@ -79,7 +79,7 @@ class NeighborhoodAllocator
7979
/** Copy constructor. */
8080
NeighborhoodAllocator(const Self & other)
8181
: m_ElementCount(other.m_ElementCount)
82-
, m_Data(new TPixel[other.m_ElementCount])
82+
, m_Data(make_unique_for_overwrite<TPixel[]>(other.m_ElementCount))
8383
{
8484
std::copy_n(other.m_Data.get(), m_ElementCount, m_Data.get());
8585
}

0 commit comments

Comments
 (0)