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

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() ...@@ -236,11 +236,8 @@ vtkAxisActor::~vtkAxisActor()
this->Point2Coordinate = NULL; this->Point2Coordinate = NULL;
} }
if (this->LabelFormat) delete [] this->LabelFormat;
{ this->LabelFormat = NULL;
delete [] this->LabelFormat;
this->LabelFormat = NULL;
}
if (this->TitleVector) if (this->TitleVector)
{ {
...@@ -267,11 +264,8 @@ vtkAxisActor::~vtkAxisActor() ...@@ -267,11 +264,8 @@ vtkAxisActor::~vtkAxisActor()
this->TitleActor2D = NULL; this->TitleActor2D = NULL;
} }
if (this->Title) delete [] this->Title;
{ this->Title = NULL;
delete [] this->Title;
this->Title = NULL;
}
if (this->TitleTextProperty) if (this->TitleTextProperty)
{ {
...@@ -1745,10 +1739,7 @@ void vtkAxisActor::SetTitle(const char *t) ...@@ -1745,10 +1739,7 @@ void vtkAxisActor::SetTitle(const char *t)
{ {
return; return;
} }
if (this->Title) delete [] this->Title;
{
delete [] this->Title;
}
if (t) if (t)
{ {
this->Title = new char[strlen(t)+1]; this->Title = new char[strlen(t)+1];
......
...@@ -115,20 +115,14 @@ vtkAxisActor2D::vtkAxisActor2D() ...@@ -115,20 +115,14 @@ vtkAxisActor2D::vtkAxisActor2D()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
vtkAxisActor2D::~vtkAxisActor2D() vtkAxisActor2D::~vtkAxisActor2D()
{ {
if (this->LabelFormat) delete [] this->LabelFormat;
{ this->LabelFormat = NULL;
delete [] this->LabelFormat;
this->LabelFormat = NULL;
}
this->TitleMapper->Delete(); this->TitleMapper->Delete();
this->TitleActor->Delete(); this->TitleActor->Delete();
if (this->Title) delete [] this->Title;
{ this->Title = NULL;
delete [] this->Title;
this->Title = NULL;
}
if (this->LabelMappers != NULL ) if (this->LabelMappers != NULL )
{ {
......
...@@ -135,11 +135,8 @@ vtkBarChartActor::~vtkBarChartActor() ...@@ -135,11 +135,8 @@ vtkBarChartActor::~vtkBarChartActor()
this->Input = NULL; this->Input = NULL;
} }
if (this->Title) delete [] this->Title;
{ this->Title = NULL;
delete [] this->Title;
this->Title = NULL;
}
delete this->Labels; delete this->Labels;
this->SetLabelTextProperty(NULL); this->SetLabelTextProperty(NULL);
...@@ -156,10 +153,7 @@ vtkBarChartActor::~vtkBarChartActor() ...@@ -156,10 +153,7 @@ vtkBarChartActor::~vtkBarChartActor()
this->TitleActor = NULL; this->TitleActor = NULL;
this->YAxis->Delete(); this->YAxis->Delete();
if ( this->YTitle ) delete [] this->YTitle;
{
delete [] this->YTitle;
}
this->PlotData->Delete(); this->PlotData->Delete();
this->PlotMapper->Delete(); this->PlotMapper->Delete();
...@@ -184,11 +178,8 @@ void vtkBarChartActor::Initialize() ...@@ -184,11 +178,8 @@ void vtkBarChartActor::Initialize()
} }
this->N = 0; this->N = 0;
if ( this->Heights ) delete [] this->Heights;
{ this->Heights = NULL;
delete [] this->Heights;
this->Heights = NULL;
}
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
......
...@@ -481,71 +481,41 @@ vtkCubeAxesActor::~vtkCubeAxesActor() ...@@ -481,71 +481,41 @@ vtkCubeAxesActor::~vtkCubeAxesActor()
this->LabelTextProperty[i] = NULL; 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;
delete [] this->XTitle;
this->XTitle = NULL;
}
if (this->YTitle)
{
delete [] this->YTitle;
this->YTitle = NULL;
}
if (this->ZTitle)
{
delete [] this->ZTitle;
this->ZTitle = NULL;
}
if (this->XUnits) delete [] this->YTitle;
{ this->YTitle = NULL;
delete [] this->XUnits;
this->XUnits = NULL;
}
if (this->YUnits)
{
delete [] this->YUnits;
this->YUnits = NULL;
}
if (this->ZUnits)
{
delete [] this->ZUnits;
this->ZUnits = NULL;
}
if (this->ActualXLabel) delete [] this->ZTitle;
{ this->ZTitle = NULL;
delete [] this->ActualXLabel;
this->ActualXLabel = NULL; delete [] this->XUnits;
} this->XUnits = NULL;
if (this->ActualYLabel)
{ delete [] this->YUnits;
delete [] this->ActualYLabel; this->YUnits = NULL;
this->ActualYLabel = NULL;
} delete [] this->ZUnits;
if (this->ActualZLabel) this->ZUnits = NULL;
{
delete [] this->ActualZLabel; delete [] this->ActualXLabel;
this->ActualZLabel = NULL; this->ActualXLabel = NULL;
}
delete [] this->ActualYLabel;
this->ActualYLabel = NULL;
delete [] this->ActualZLabel;
this->ActualZLabel = NULL;
} }
// ************************************************************************* // *************************************************************************
......
...@@ -156,24 +156,12 @@ vtkCubeAxesActor2D::~vtkCubeAxesActor2D() ...@@ -156,24 +156,12 @@ vtkCubeAxesActor2D::~vtkCubeAxesActor2D()
this->YAxis->Delete(); this->YAxis->Delete();
this->ZAxis->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;
{ delete [] this->YLabel;
delete [] this->XLabel; delete [] this->ZLabel;
}
if ( this->YLabel )
{
delete [] this->YLabel;
}
if ( this->ZLabel )
{
delete [] this->ZLabel;
}
this->SetAxisLabelTextProperty(NULL); this->SetAxisLabelTextProperty(NULL);
this->SetAxisTitleTextProperty(NULL); this->SetAxisTitleTextProperty(NULL);
......
...@@ -100,16 +100,11 @@ vtkLeaderActor2D::~vtkLeaderActor2D() ...@@ -100,16 +100,11 @@ vtkLeaderActor2D::~vtkLeaderActor2D()
this->LabelMapper->Delete(); this->LabelMapper->Delete();
this->LabelActor->Delete(); this->LabelActor->Delete();
if (this->Label) delete [] this->Label;
{ this->Label = NULL;
delete [] this->Label;
this->Label = NULL; delete [] this->LabelFormat;
} this->LabelFormat = NULL;
if (this->LabelFormat)
{
delete [] this->LabelFormat;
this->LabelFormat = NULL;
}
this->LeaderPoints->Delete(); this->LeaderPoints->Delete();
this->LeaderLines->Delete(); this->LeaderLines->Delete();
......
...@@ -118,17 +118,11 @@ vtkParallelCoordinatesActor::~vtkParallelCoordinatesActor() ...@@ -118,17 +118,11 @@ vtkParallelCoordinatesActor::~vtkParallelCoordinatesActor()
this->PlotMapper->Delete(); this->PlotMapper->Delete();
this->PlotActor->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->SetLabelTextProperty(NULL);
this->SetTitleTextProperty(NULL); this->SetTitleTextProperty(NULL);
......
...@@ -142,11 +142,8 @@ vtkPieChartActor::~vtkPieChartActor() ...@@ -142,11 +142,8 @@ vtkPieChartActor::~vtkPieChartActor()
this->ConnectionHolder->Delete(); this->ConnectionHolder->Delete();
this->ConnectionHolder = 0; this->ConnectionHolder = 0;
if (this->Title) delete [] this->Title;
{ this->Title = NULL;
delete [] this->Title;
this->Title = NULL;
}
delete this->Labels; delete this->Labels;
this->SetLabelTextProperty(NULL); this->SetLabelTextProperty(NULL);
...@@ -211,10 +208,7 @@ void vtkPieChartActor::Initialize() ...@@ -211,10 +208,7 @@ void vtkPieChartActor::Initialize()
this->N = 0; this->N = 0;
this->Total = 0.0; this->Total = 0.0;
if ( this->Fractions ) delete [] this->Fractions;
{
delete [] this->Fractions;
}
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
......
...@@ -245,17 +245,11 @@ vtkPolarAxesActor::~vtkPolarAxesActor() ...@@ -245,17 +245,11 @@ vtkPolarAxesActor::~vtkPolarAxesActor()
this->RadialAxesProperty->Delete(); 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 ) if ( this->PolarAxisTitleTextProperty )
{ {
......
...@@ -287,11 +287,8 @@ void vtkScalarBarActor::GetScalarBarRect(int rect[4], vtkViewport* viewport) ...@@ -287,11 +287,8 @@ void vtkScalarBarActor::GetScalarBarRect(int rect[4], vtkViewport* viewport)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
vtkScalarBarActor::~vtkScalarBarActor() vtkScalarBarActor::~vtkScalarBarActor()
{ {
if (this->LabelFormat) delete [] this->LabelFormat;
{ this->LabelFormat = NULL;
delete [] this->LabelFormat;
this->LabelFormat = NULL;
}
this->TitleActor->Delete(); this->TitleActor->Delete();
this->SetNanAnnotation(NULL); this->SetNanAnnotation(NULL);
...@@ -312,17 +309,11 @@ vtkScalarBarActor::~vtkScalarBarActor() ...@@ -312,17 +309,11 @@ vtkScalarBarActor::~vtkScalarBarActor()
this->P->AnnotationLeadersMapper->Delete(); this->P->AnnotationLeadersMapper->Delete();
this->P->AnnotationLeadersActor->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->SetLookupTable(NULL);
this->SetLabelTextProperty(NULL); this->SetLabelTextProperty(NULL);
......
...@@ -155,11 +155,8 @@ vtkSpiderPlotActor::~vtkSpiderPlotActor() ...@@ -155,11 +155,8 @@ vtkSpiderPlotActor::~vtkSpiderPlotActor()
this->ConnectionHolder->Delete(); this->ConnectionHolder->Delete();
this->ConnectionHolder = 0; this->ConnectionHolder = 0;
if (this->Title) delete [] this->Title;
{ this->Title = NULL;
delete [] this->Title;
this->Title = NULL;
}
delete this->Labels; delete this->Labels;
delete this->Ranges; delete this->Ranges;
......
...@@ -2821,10 +2821,7 @@ void vtkXYPlotActor::SetXLabelFormat( const char* _arg ) ...@@ -2821,10 +2821,7 @@ void vtkXYPlotActor::SetXLabelFormat( const char* _arg )
return; return;
} }
if ( this->XLabelFormat ) delete [] this->XLabelFormat;
{
delete [] this->XLabelFormat;
}
if (_arg ) if (_arg )
{ {
...@@ -2854,10 +2851,7 @@ void vtkXYPlotActor::SetYLabelFormat( const char* _arg ) ...@@ -2854,10 +2851,7 @@ void vtkXYPlotActor::SetYLabelFormat( const char* _arg )
return; return;
} }
if ( this->YLabelFormat ) delete [] this->YLabelFormat;
{
delete [] this->YLabelFormat;
}
if (_arg ) if (_arg )
{ {
......
...@@ -257,11 +257,8 @@ vtkColorTransferFunction::~vtkColorTransferFunction() ...@@ -257,11 +257,8 @@ vtkColorTransferFunction::~vtkColorTransferFunction()
{ {
delete [] this->Table; 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++) for(unsigned int i=0;i<this->Internal->Nodes.size();i++)
{ {
...@@ -284,11 +281,8 @@ double *vtkColorTransferFunction::GetDataPointer() ...@@ -284,11 +281,8 @@ double *vtkColorTransferFunction::GetDataPointer()
{ {
int size = static_cast<int>(this->Internal->Nodes.size()); 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 ) if ( size > 0 )
{ {
......
...@@ -52,10 +52,7 @@ vtkInteractorEventRecorder::~vtkInteractorEventRecorder() ...@@ -52,10 +52,7 @@ vtkInteractorEventRecorder::~vtkInteractorEventRecorder()
{ {
this->SetInteractor(0); this->SetInteractor(0);
if ( this->FileName ) delete [] this->FileName;
{
delete [] this->FileName;
}
if ( this->InputStream ) if ( this->InputStream )
{ {
...@@ -64,17 +61,11 @@ vtkInteractorEventRecorder::~vtkInteractorEventRecorder() ...@@ -64,17 +61,11 @@ vtkInteractorEventRecorder::~vtkInteractorEventRecorder()
this->InputStream = NULL; 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() ...@@ -53,10 +53,8 @@ vtkProp::~vtkProp()
{ {
this->Paths->Delete(); this->Paths->Delete();
} }
if (this->Consumers)
{ delete [] this->Consumers;
delete [] this->Consumers;
}
if(this->PropertyKeys!=0) if(this->PropertyKeys!=0)
{ {
......
...@@ -96,24 +96,16 @@ vtkRenderWindow::~vtkRenderWindow() ...@@ -96,24 +96,16 @@ vtkRenderWindow::~vtkRenderWindow()
{ {
this->SetInteractor(NULL); this->SetInteractor(NULL);