Commit 8812203b authored by Sean McBride's avatar Sean McBride

Conservative elimination of !null checks before 'delete'

C++ guarantees that delete 0 and delete [] 0 do nothing.
Older buggy compilers that didn't honour this are no longer
supported by VTK.  Conservatively removed many "if (!ptr)"
checks before using delete in /Common.

Change-Id: I451f353ba57487432904487d61107cf7bb818b8e
parent 004cad2e
......@@ -236,11 +236,8 @@ vtkAxisActor::~vtkAxisActor()
this->Point2Coordinate = NULL;
}
if (this->LabelFormat)
{
delete [] this->LabelFormat;
this->LabelFormat = NULL;
}
delete [] this->LabelFormat;
this->LabelFormat = NULL;
if (this->TitleVector)
{
......@@ -267,11 +264,8 @@ vtkAxisActor::~vtkAxisActor()
this->TitleActor2D = NULL;
}
if (this->Title)
{
delete [] this->Title;
this->Title = NULL;
}
delete [] this->Title;
this->Title = NULL;
if (this->TitleTextProperty)
{
......@@ -1745,10 +1739,7 @@ void vtkAxisActor::SetTitle(const char *t)
{
return;
}
if (this->Title)
{
delete [] this->Title;
}
delete [] this->Title;
if (t)
{
this->Title = new char[strlen(t)+1];
......
......@@ -115,20 +115,14 @@ vtkAxisActor2D::vtkAxisActor2D()
//----------------------------------------------------------------------------
vtkAxisActor2D::~vtkAxisActor2D()
{
if (this->LabelFormat)
{
delete [] this->LabelFormat;
this->LabelFormat = NULL;
}
delete [] this->LabelFormat;
this->LabelFormat = NULL;
this->TitleMapper->Delete();
this->TitleActor->Delete();
if (this->Title)
{
delete [] this->Title;
this->Title = NULL;
}
delete [] this->Title;
this->Title = NULL;
if (this->LabelMappers != NULL )
{
......
......@@ -135,11 +135,8 @@ vtkBarChartActor::~vtkBarChartActor()
this->Input = NULL;
}
if (this->Title)
{
delete [] this->Title;
this->Title = NULL;
}
delete [] this->Title;
this->Title = NULL;
delete this->Labels;
this->SetLabelTextProperty(NULL);
......@@ -156,10 +153,7 @@ vtkBarChartActor::~vtkBarChartActor()
this->TitleActor = NULL;
this->YAxis->Delete();
if ( this->YTitle )
{
delete [] this->YTitle;
}
delete [] this->YTitle;
this->PlotData->Delete();
this->PlotMapper->Delete();
......@@ -184,11 +178,8 @@ void vtkBarChartActor::Initialize()
}
this->N = 0;
if ( this->Heights )
{
delete [] this->Heights;
this->Heights = NULL;
}
delete [] this->Heights;
this->Heights = NULL;
}
//----------------------------------------------------------------------------
......
......@@ -481,71 +481,41 @@ vtkCubeAxesActor::~vtkCubeAxesActor()
this->LabelTextProperty[i] = NULL;
}
if (this->XLabelFormat)
{
delete [] this->XLabelFormat;
this->XLabelFormat = NULL;
}
delete [] this->XLabelFormat;
this->XLabelFormat = NULL;
if (this->YLabelFormat)
{
delete [] this->YLabelFormat;
this->YLabelFormat = NULL;
}
delete [] this->YLabelFormat;
this->YLabelFormat = NULL;
if (this->ZLabelFormat)
{
delete [] this->ZLabelFormat;
this->ZLabelFormat = NULL;
}
delete [] this->ZLabelFormat;
this->ZLabelFormat = NULL;
if (this->XTitle)
{
delete [] this->XTitle;
this->XTitle = NULL;
}
if (this->YTitle)
{
delete [] this->YTitle;
this->YTitle = NULL;
}
if (this->ZTitle)
{
delete [] this->ZTitle;
this->ZTitle = NULL;
}
delete [] this->XTitle;
this->XTitle = NULL;
if (this->XUnits)
{
delete [] this->XUnits;
this->XUnits = NULL;
}
if (this->YUnits)
{
delete [] this->YUnits;
this->YUnits = NULL;
}
if (this->ZUnits)
{
delete [] this->ZUnits;
this->ZUnits = NULL;
}
delete [] this->YTitle;
this->YTitle = NULL;
if (this->ActualXLabel)
{
delete [] this->ActualXLabel;
this->ActualXLabel = NULL;
}
if (this->ActualYLabel)
{
delete [] this->ActualYLabel;
this->ActualYLabel = NULL;
}
if (this->ActualZLabel)
{
delete [] this->ActualZLabel;
this->ActualZLabel = NULL;
}
delete [] this->ZTitle;
this->ZTitle = NULL;
delete [] this->XUnits;
this->XUnits = NULL;
delete [] this->YUnits;
this->YUnits = NULL;
delete [] this->ZUnits;
this->ZUnits = NULL;
delete [] this->ActualXLabel;
this->ActualXLabel = NULL;
delete [] this->ActualYLabel;
this->ActualYLabel = NULL;
delete [] this->ActualZLabel;
this->ActualZLabel = NULL;
}
// *************************************************************************
......
......@@ -156,24 +156,12 @@ vtkCubeAxesActor2D::~vtkCubeAxesActor2D()
this->YAxis->Delete();
this->ZAxis->Delete();
if (this->LabelFormat)
{
delete [] this->LabelFormat;
this->LabelFormat = NULL;
}
delete [] this->LabelFormat;
this->LabelFormat = NULL;
if ( this->XLabel )
{
delete [] this->XLabel;
}
if ( this->YLabel )
{
delete [] this->YLabel;
}
if ( this->ZLabel )
{
delete [] this->ZLabel;
}
delete [] this->XLabel;
delete [] this->YLabel;
delete [] this->ZLabel;
this->SetAxisLabelTextProperty(NULL);
this->SetAxisTitleTextProperty(NULL);
......
......@@ -100,16 +100,11 @@ vtkLeaderActor2D::~vtkLeaderActor2D()
this->LabelMapper->Delete();
this->LabelActor->Delete();
if (this->Label)
{
delete [] this->Label;
this->Label = NULL;
}
if (this->LabelFormat)
{
delete [] this->LabelFormat;
this->LabelFormat = NULL;
}
delete [] this->Label;
this->Label = NULL;
delete [] this->LabelFormat;
this->LabelFormat = NULL;
this->LeaderPoints->Delete();
this->LeaderLines->Delete();
......
......@@ -118,17 +118,11 @@ vtkParallelCoordinatesActor::~vtkParallelCoordinatesActor()
this->PlotMapper->Delete();
this->PlotActor->Delete();
if (this->Title)
{
delete [] this->Title;
this->Title = NULL;
}
delete [] this->Title;
this->Title = NULL;
if (this->LabelFormat)
{
delete [] this->LabelFormat;
this->LabelFormat = NULL;
}
delete [] this->LabelFormat;
this->LabelFormat = NULL;
this->SetLabelTextProperty(NULL);
this->SetTitleTextProperty(NULL);
......
......@@ -142,11 +142,8 @@ vtkPieChartActor::~vtkPieChartActor()
this->ConnectionHolder->Delete();
this->ConnectionHolder = 0;
if (this->Title)
{
delete [] this->Title;
this->Title = NULL;
}
delete [] this->Title;
this->Title = NULL;
delete this->Labels;
this->SetLabelTextProperty(NULL);
......@@ -211,10 +208,7 @@ void vtkPieChartActor::Initialize()
this->N = 0;
this->Total = 0.0;
if ( this->Fractions )
{
delete [] this->Fractions;
}
delete [] this->Fractions;
}
//----------------------------------------------------------------------------
......
......@@ -245,17 +245,11 @@ vtkPolarAxesActor::~vtkPolarAxesActor()
this->RadialAxesProperty->Delete();
}
if ( this->PolarLabelFormat )
{
delete [] this->PolarLabelFormat;
this->PolarLabelFormat = NULL;
}
delete [] this->PolarLabelFormat;
this->PolarLabelFormat = NULL;
if ( this->PolarAxisTitle )
{
delete [] this->PolarAxisTitle;
this->PolarAxisTitle = NULL;
}
delete [] this->PolarAxisTitle;
this->PolarAxisTitle = NULL;
if ( this->PolarAxisTitleTextProperty )
{
......
......@@ -287,11 +287,8 @@ void vtkScalarBarActor::GetScalarBarRect(int rect[4], vtkViewport* viewport)
//----------------------------------------------------------------------------
vtkScalarBarActor::~vtkScalarBarActor()
{
if (this->LabelFormat)
{
delete [] this->LabelFormat;
this->LabelFormat = NULL;
}
delete [] this->LabelFormat;
this->LabelFormat = NULL;
this->TitleActor->Delete();
this->SetNanAnnotation(NULL);
......@@ -312,17 +309,11 @@ vtkScalarBarActor::~vtkScalarBarActor()
this->P->AnnotationLeadersMapper->Delete();
this->P->AnnotationLeadersActor->Delete();
if (this->Title)
{
delete [] this->Title;
this->Title = NULL;
}
delete [] this->Title;
this->Title = NULL;
if ( this->ComponentTitle )
{
delete [] this->ComponentTitle;
this->ComponentTitle = NULL;
}
delete [] this->ComponentTitle;
this->ComponentTitle = NULL;
this->SetLookupTable(NULL);
this->SetLabelTextProperty(NULL);
......
......@@ -155,11 +155,8 @@ vtkSpiderPlotActor::~vtkSpiderPlotActor()
this->ConnectionHolder->Delete();
this->ConnectionHolder = 0;
if (this->Title)
{
delete [] this->Title;
this->Title = NULL;
}
delete [] this->Title;
this->Title = NULL;
delete this->Labels;
delete this->Ranges;
......
......@@ -2821,10 +2821,7 @@ void vtkXYPlotActor::SetXLabelFormat( const char* _arg )
return;
}
if ( this->XLabelFormat )
{
delete [] this->XLabelFormat;
}
delete [] this->XLabelFormat;
if (_arg )
{
......@@ -2854,10 +2851,7 @@ void vtkXYPlotActor::SetYLabelFormat( const char* _arg )
return;
}
if ( this->YLabelFormat )
{
delete [] this->YLabelFormat;
}
delete [] this->YLabelFormat;
if (_arg )
{
......
......@@ -257,11 +257,8 @@ vtkColorTransferFunction::~vtkColorTransferFunction()
{
delete [] this->Table;
if ( this->Function )
{
delete [] this->Function;
this->Function = NULL;
}
delete [] this->Function;
this->Function = NULL;
for(unsigned int i=0;i<this->Internal->Nodes.size();i++)
{
......@@ -284,11 +281,8 @@ double *vtkColorTransferFunction::GetDataPointer()
{
int size = static_cast<int>(this->Internal->Nodes.size());
if ( this->Function )
{
delete [] this->Function;
this->Function = NULL;
}
delete [] this->Function;
this->Function = NULL;
if ( size > 0 )
{
......
......@@ -52,10 +52,7 @@ vtkInteractorEventRecorder::~vtkInteractorEventRecorder()
{
this->SetInteractor(0);
if ( this->FileName )
{
delete [] this->FileName;
}
delete [] this->FileName;
if ( this->InputStream )
{
......@@ -64,17 +61,11 @@ vtkInteractorEventRecorder::~vtkInteractorEventRecorder()
this->InputStream = NULL;
}
if ( this->OutputStream )
{
delete this->OutputStream;
this->OutputStream = NULL;
}
delete this->OutputStream;
this->OutputStream = NULL;
if ( this->InputString )
{
delete [] this->InputString;
this->InputString = NULL;
}
delete [] this->InputString;
this->InputString = NULL;
}
//----------------------------------------------------------------------------
......
......@@ -53,10 +53,8 @@ vtkProp::~vtkProp()
{
this->Paths->Delete();
}
if (this->Consumers)
{
delete [] this->Consumers;
}
delete [] this->Consumers;
if(this->PropertyKeys!=0)
{
......
......@@ -96,24 +96,16 @@ vtkRenderWindow::~vtkRenderWindow()
{
this->SetInteractor(NULL);
if (this->AccumulationBuffer)
{
delete [] this->AccumulationBuffer;
this->AccumulationBuffer = NULL;
this->AccumulationBufferSize = 0;
}
if (this->ResultFrame)
{
delete [] this->ResultFrame;
this->ResultFrame = NULL;
}
delete [] this->AccumulationBuffer;
this->AccumulationBuffer = NULL;
this->AccumulationBufferSize = 0;
delete [] this->ResultFrame;
this->ResultFrame = NULL;
for (int i = 0; i < 2; ++i)
{
if (this->ConstantFDOffsets[i])
{
delete [] this->ConstantFDOffsets[i];
}
delete [] this->ConstantFDOffsets[i];
this->ConstantFDOffsets[i] = NULL;
}
......@@ -180,11 +172,9 @@ void vtkRenderWindow::SetFDFrames(int fdFrames)
for (int i = 0; i < 2; i++)
{
if (this->ConstantFDOffsets[i])
{
delete [] this->ConstantFDOffsets[i];
}
delete [] this->ConstantFDOffsets[i];
this->ConstantFDOffsets[i] = NULL;
if (this->FDFrames > 0)
{
this->ConstantFDOffsets[i] = new double[this->FDFrames];
......@@ -475,11 +465,8 @@ void vtkRenderWindow::Render()
this->CopyResultFrame();
}
if (this->ResultFrame)
{
delete [] this->ResultFrame;
this->ResultFrame = NULL;
}
delete [] this->ResultFrame;
this->ResultFrame = NULL;
this->InRender = 0;
this->InvokeEvent(vtkCommand::EndEvent,NULL);
......
......@@ -133,10 +133,7 @@ vtkRenderWindowInteractor::~vtkRenderWindowInteractor()
{
this->Picker->UnRegister(this);
}
if ( this->KeySym )
{
delete [] this->KeySym;
}
delete [] this->KeySym;
if ( this->ObserverMediator)
{
this->ObserverMediator->Delete();
......
......@@ -139,10 +139,7 @@ vtkRenderer::~vtkRenderer()
this->CreatedLight = NULL;
}
if (this->BackingImage)
{
delete [] this->BackingImage;
}
delete [] this->BackingImage;
this->Actors->Delete();
this->Actors = NULL;
......@@ -308,18 +305,12 @@ void vtkRenderer::Render(void)
// Clean up the space we allocated before. If the PropArray exists,
// they all should exist
if ( this->PropArray)
{
delete [] this->PropArray;
this->PropArray = NULL;
}
delete [] this->PropArray;
this->PropArray = NULL;
if (this->BackingStore)
{
if (this->BackingImage)
{
delete [] this->BackingImage;
}
delete [] this->BackingImage;
int rx1, ry1, rx2, ry2;
......
......@@ -189,21 +189,14 @@ public:
this->NumberOfValues = x.GetNumberOfValues();
this->Type = x.GetType();
if (this->IntValues)
{
delete [] this->IntValues;
this->IntValues = NULL;
}
if (this->FloatValues)
{
delete [] this->FloatValues;
this->FloatValues = NULL;
}
if (this->DoubleValues)
{
delete [] this->DoubleValues;
this->DoubleValues = NULL;
}
delete [] this->IntValues;
this->IntValues = NULL;
delete [] this->FloatValues;
this->FloatValues = NULL;
delete [] this->DoubleValues;
this->DoubleValues = NULL;
if ( (this->Type == VTK_INT) && (this->NumberOfValues > 0) )
{
......@@ -270,21 +263,14 @@ public:
~vtkShaderUniformVariable()
{
if (this->IntValues)
{
delete [] this->IntValues;
this->IntValues = NULL;
}
if (this->FloatValues)
{
delete [] this->FloatValues;
this->FloatValues = NULL;
}
if (this->DoubleValues)
{
delete [] this->DoubleValues;
this->DoubleValues = NULL;
}
delete [] this->IntValues;
this->IntValues = NULL;
delete [] this->FloatValues;
this->FloatValues = NULL;
delete [] this->DoubleValues;
this->DoubleValues = NULL;
}
void Print(ostream& os, vtkIndent indent)
......
......@@ -50,11 +50,7 @@ void vtkTextMapper::ShallowCopy(vtkTextMapper *tm)
//----------------------------------------------------------------------------
vtkTextMapper::~vtkTextMapper()
{
if (this->Input)
{
delete [] this->Input;
this->Input = NULL;
}
delete [] this->Input;
if (this->TextLines != NULL)
{
......@@ -304,10 +300,7 @@ void vtkTextMapper::SetInput(const char *input)
{
return;
}
if (this->Input)
{
delete [] this->Input;
}
delete [] this->Input;
if (input)
{
this->Input = new char[strlen(input)+1];
......
......@@ -66,25 +66,10 @@ vtkVolume::~vtkVolume()
for ( int i = 0; i < VTK_MAX_VRCOMP; i++ )
{
if ( this->ScalarOpacityArray[i] )
{
delete [] this->ScalarOpacityArray[i];
}
if ( this->RGBArray[i] )
{
delete [] this->RGBArray[i];
}
if ( this->GrayArray[i] )
{
delete [] this->GrayArray[i];
}
if ( this->CorrectedScalarOpacityArray[i] )
{
delete [] this->CorrectedScalarOpacityArray[i];
}
delete [] this->ScalarOpacityArray[i];
delete [] this->RGBArray[i];
delete [] this->GrayArray[i];
delete [] this->CorrectedScalarOpacityArray[i];
}
}
......@@ -570,26 +555,17 @@ void vtkVolume::UpdateTransferFunctions( vtkRenderer *vtkNotUsed(ren) )
// opacity
if ( arraySize != this->ArraySize )
{
if ( this->ScalarOpacityArray[c] )
{
delete [] this->ScalarOpacityArray[c];
this->ScalarOpacityArray[c] = NULL;
}
if ( this->CorrectedScalarOpacityArray[c] )
{
delete [] this->CorrectedScalarOpacityArray[c];
this->CorrectedScalarOpacityArray[c] = NULL;
}
if ( this->GrayArray[c] )
{
delete [] this->GrayArray[c];
this->GrayArray[c] = NULL;
}