Skip to content

Commit 038880c

Browse files
committed
STYLE: Replace Allocate(true) with AllocateInitialized() for readability
AllocateInitialized() is an alias for Allocate(true) introduced in itkImageBase.h to make zero-initialization intent explicit in code. Replace all call sites in Modules/ and Examples/. The trailing "// initialize buffer to zero" comments are also removed since AllocateInitialized() is self-documenting. Suggested by N-Dekker in ITK PR InsightSoftwareConsortium#6003.
1 parent b94cca5 commit 038880c

7 files changed

Lines changed: 8 additions & 8 deletions

File tree

Examples/DataRepresentation/Image/Image3.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ main(int, char *[])
5656

5757
// Pixel data is allocated
5858
image->SetRegions(region);
59-
image->Allocate(true); // initialize buffer to zero
59+
image->AllocateInitialized();
6060

6161

6262
// Software Guide : BeginLatex

Examples/DataRepresentation/Image/Image4.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ main(int, char *[])
9393
region.SetIndex(start);
9494

9595
image->SetRegions(region);
96-
image->Allocate(true); // initialize buffer to zero
96+
image->AllocateInitialized();
9797

9898
// Software Guide : BeginLatex
9999
//

Examples/Filtering/DigitallyReconstructedRadiograph1.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ main(int argc, char * argv[])
381381
region.SetIndex(start);
382382

383383
image->SetRegions(region);
384-
image->Allocate(true); // initialize to zero.
384+
image->AllocateInitialized();
385385

386386
image->Update();
387387

Examples/Segmentation/HoughTransform2DCirclesImageFilter.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ main(int argc, char * argv[])
203203
localOutputImage->SetRegions(region);
204204
localOutputImage->SetOrigin(localImage->GetOrigin());
205205
localOutputImage->SetSpacing(localImage->GetSpacing());
206-
localOutputImage->Allocate(true); // initializes buffer to zero
206+
localOutputImage->AllocateInitialized();
207207
// Software Guide : EndCodeSnippet
208208

209209

Examples/Segmentation/HoughTransform2DLinesImageFilter.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ main(int argc, char * argv[])
219219
localImage->GetLargestPossibleRegion());
220220
localOutputImage->SetRegions(region);
221221
localOutputImage->CopyInformation(localImage);
222-
localOutputImage->Allocate(true); // initialize buffer to zero
222+
localOutputImage->AllocateInitialized();
223223
// Software Guide : EndCodeSnippet
224224

225225

Examples/SpatialObjects/ImageMaskSpatialObject.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ main(int, char *[])
7676
region.SetIndex(index);
7777

7878
image->SetRegions(region);
79-
image->Allocate(true); // initialize buffer to zero
79+
image->AllocateInitialized();
8080

8181
ImageType::RegionType insideRegion;
8282
constexpr ImageType::SizeType insideSize = { { 30, 30, 30 } };

Modules/IO/TransformMINC/src/itkMINCTransformIO.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ MINCTransformIOTemplate<TParametersValueType>::ReadOneTransform(VIO_General_tran
180180
{
181181
LPSgrid->CopyInformation(grid);
182182
LPSgrid->SetRegions(grid->GetBufferedRegion());
183-
LPSgrid->Allocate(true);
183+
LPSgrid->AllocateInitialized();
184184

185185
itk::MultiThreaderBase::Pointer mt = itk::MultiThreaderBase::New();
186186
mt->ParallelizeImageRegion<3>(
@@ -361,7 +361,7 @@ MINCTransformIOTemplate<TParametersValueType>::WriteOneTransform(const int
361361
typename GridImageType::Pointer rasGrid = GridImageType::New(); // flipped grid for RAS->LPS conversion
362362
rasGrid->CopyInformation(grid);
363363
rasGrid->SetRegions(grid->GetBufferedRegion());
364-
rasGrid->Allocate(true);
364+
rasGrid->AllocateInitialized();
365365

366366
itk::MultiThreaderBase::Pointer mt = itk::MultiThreaderBase::New();
367367
mt->ParallelizeImageRegion<3>(

0 commit comments

Comments
 (0)