Commit de54031e authored by Sean McBride's avatar Sean McBride

Eliminated unneeded null checks before using delete/free

Change-Id: I76fea205f42b796bcfc5d47b6f171d39eadd44a4
parent fe69c242
......@@ -721,11 +721,8 @@ bool vtkPlotPoints::UpdateTableCache(vtkTable *table)
this->CalculateLogSeries();
this->FindBadPoints();
this->Points->Modified();
if (this->Sorted)
{
delete this->Sorted;
this->Sorted = 0;
}
delete this->Sorted;
this->Sorted = 0;
// Additions for color mapping
if (this->ScalarVisibility && !this->ColorArrayName.empty())
......
......@@ -92,10 +92,7 @@ vtkAbstractArray::~vtkAbstractArray()
{
for ( unsigned int i=0; i < this->ComponentNames->size(); ++i)
{
if ( this->ComponentNames->at(i) )
{
delete this->ComponentNames->at(i);
}
delete this->ComponentNames->at(i);
}
this->ComponentNames->clear();
delete this->ComponentNames;
......@@ -179,10 +176,7 @@ int vtkAbstractArray::CopyComponentNames( vtkAbstractArray *da )
//copy the passed in components
for ( unsigned int i=0; i < this->ComponentNames->size(); ++i)
{
if ( this->ComponentNames->at(i) )
{
delete this->ComponentNames->at(i);
}
delete this->ComponentNames->at(i);
}
this->ComponentNames->clear();
this->ComponentNames->reserve( da->ComponentNames->size() );
......
......@@ -699,9 +699,6 @@ void vtkBitArray::DataChanged()
//----------------------------------------------------------------------------
void vtkBitArray::ClearLookup()
{
if (this->Lookup)
{
delete this->Lookup;
this->Lookup = NULL;
}
delete this->Lookup;
this->Lookup = NULL;
}
......@@ -90,14 +90,8 @@ template <class T>
vtkDataArrayTemplate<T>::~vtkDataArrayTemplate()
{
this->DeleteArray();
if(this->Tuple)
{
free(this->Tuple);
}
if(this->Lookup)
{
delete this->Lookup;
}
free(this->Tuple);
delete this->Lookup;
}
//----------------------------------------------------------------------------
......@@ -1236,11 +1230,8 @@ void vtkDataArrayTemplate<T>::DataElementChanged(vtkIdType id)
template <class T>
void vtkDataArrayTemplate<T>::ClearLookup()
{
if (this->Lookup)
{
delete this->Lookup;
this->Lookup = NULL;
}
delete this->Lookup;
this->Lookup = NULL;
}
#endif
......@@ -103,10 +103,7 @@ public:
for (int i = 0; i < 64; i++)
{
vtkDebugLeaksHashNode *pos = this->Nodes[i];
if(pos)
{
delete pos;
}
delete pos;
}
}
......
......@@ -27,14 +27,8 @@ vtkFileOutputWindow::vtkFileOutputWindow()
vtkFileOutputWindow::~vtkFileOutputWindow()
{
if (this->FileName)
{
delete[] this->FileName;
}
if (this->OStream)
{
delete this->OStream;
}
delete[] this->FileName;
delete this->OStream;
}
void vtkFileOutputWindow::Initialize()
......
......@@ -32,12 +32,9 @@ vtkMappedDataArray<Scalar>::vtkMappedDataArray()
template<class Scalar>
vtkMappedDataArray<Scalar>::~vtkMappedDataArray()
{
if (this->TemporaryScalarPointer)
{
delete [] this->TemporaryScalarPointer;
this->TemporaryScalarPointer = NULL;
this->TemporaryScalarPointerSize = 0;
}
delete [] this->TemporaryScalarPointer;
this->TemporaryScalarPointer = NULL;
this->TemporaryScalarPointerSize = 0;
}
//------------------------------------------------------------------------------
......
......@@ -878,11 +878,8 @@ void vtkStringArray::DataElementChanged(vtkIdType id)
//-----------------------------------------------------------------------------
void vtkStringArray::ClearLookup()
{
if (this->Lookup)
{
delete this->Lookup;
this->Lookup = NULL;
}
delete this->Lookup;
this->Lookup = NULL;
}
......
......@@ -917,9 +917,6 @@ void vtkVariantArray::DataElementChanged(vtkIdType id)
//----------------------------------------------------------------------------
void vtkVariantArray::ClearLookup()
{
if (this->Lookup)
{
delete this->Lookup;
this->Lookup = NULL;
}
delete this->Lookup;
this->Lookup = NULL;
}
......@@ -2181,11 +2181,8 @@ void vtkDataSetAttributes::FieldList::SetField(
//we unallocate the names before we update the field components
//so we unallocate correctly
if ( this->FieldComponentsNames[index] )
{
delete this->FieldComponentsNames[index];
this->FieldComponentsNames[index] = NULL;
}
delete this->FieldComponentsNames[index];
this->FieldComponentsNames[index] = NULL;
//store the components names
int numberOfComponents = aa->GetNumberOfComponents();
......
......@@ -540,10 +540,7 @@ vtkIdList **vtkEdgeTable::Resize(vtkIdType sz)
{
newPointerAttributeArray[i] = NULL;
}
if ( this->PointerAttributes )
{
delete [] this->PointerAttributes;
}
delete [] this->PointerAttributes;
this->PointerAttributes = newPointerAttributeArray;
}
......
......@@ -64,10 +64,7 @@ vtkExtractStructuredGridHelper::vtkExtractStructuredGridHelper()
//-----------------------------------------------------------------------------
vtkExtractStructuredGridHelper::~vtkExtractStructuredGridHelper()
{
if( this->IndexMap != NULL )
{
delete this->IndexMap;
}
delete this->IndexMap;
}
//-----------------------------------------------------------------------------
......
......@@ -91,10 +91,7 @@ vtkGenericAdaptorCell::~vtkGenericAdaptorCell()
this->InternalCellArray->Delete();
this->InternalIds->Delete();
if(this->Tuples!=0)
{
delete[] this->Tuples;
}
delete[] this->Tuples;
}
//----------------------------------------------------------------------------
......@@ -1113,10 +1110,7 @@ void vtkGenericAdaptorCell::AllocateTuples(int size)
if(this->TuplesCapacity<size)
{
if(this->Tuples!=0)
{
delete[] this->Tuples;
}
delete [] this->Tuples;
this->Tuples=new double[size];
this->TuplesCapacity=size;
}
......
......@@ -49,10 +49,7 @@ vtkGenericCellTessellator::vtkGenericCellTessellator()
vtkGenericCellTessellator::~vtkGenericCellTessellator()
{
this->SetErrorMetrics( 0 );
if(this->MaxErrors)
{
delete[] this->MaxErrors;
}
delete[] this->MaxErrors;
}
......@@ -191,10 +188,7 @@ void vtkGenericCellTessellator::ResetMaxErrors()
if(c>this->MaxErrorsCapacity)
{
this->MaxErrorsCapacity = c;
if(this->MaxErrors)
{
delete[] this->MaxErrors;
}
delete [] this->MaxErrors;
this->MaxErrors = new double[this->MaxErrorsCapacity];
}
......
......@@ -1327,16 +1327,11 @@ vtkSimpleCellTessellator::~vtkSimpleCellTessellator()
{
this->CellIterator->Delete();
}
if(this->Scalars)
{
delete[] this->Scalars;
}
delete[] this->Scalars;
this->Triangulator->Delete();
if(this->PointIds!=0)
{
delete[] this->PointIds;
}
delete[] this->PointIds;
this->Connectivity->Delete();
this->Polygon->Delete();
this->TriangleIds->Delete();
......@@ -2714,10 +2709,7 @@ void vtkSimpleCellTessellator::AllocatePointIds(int size)
if(this->PointIdsCapacity<size)
{
if(this->PointIds!=0)
{
delete[] this->PointIds;
}
delete[] this->PointIds;
this->PointIds=new vtkIdType[size];
this->PointIdsCapacity=size;
}
......
......@@ -38,11 +38,9 @@ vtkTreeBFSIterator::vtkTreeBFSIterator()
vtkTreeBFSIterator::~vtkTreeBFSIterator()
{
if (this->Internals)
{
delete this->Internals;
this->Internals = NULL;
}
delete this->Internals;
this->Internals = NULL;
if (this->Color)
{
this->Color->Delete();
......
......@@ -53,11 +53,9 @@ vtkTreeDFSIterator::vtkTreeDFSIterator()
vtkTreeDFSIterator::~vtkTreeDFSIterator()
{
if (this->Internals)
{
delete this->Internals;
this->Internals = NULL;
}
delete this->Internals;
this->Internals = NULL;
if (this->Color)
{
this->Color->Delete();
......
......@@ -1645,11 +1645,9 @@ void vtkAlgorithm::SetProgressText(const char* ptext)
{
return;
}
if (this->ProgressText)
{
delete[] this->ProgressText;
this->ProgressText = 0;
}
delete[] this->ProgressText;
this->ProgressText = 0;
if (ptext)
{
size_t n = strlen(ptext) + 1;
......
......@@ -64,12 +64,9 @@ vtkExtentTranslator::~vtkExtentTranslator()
//----------------------------------------------------------------------------
void vtkExtentTranslator::SetSplitPath(int len, int *sp)
{
if (this->SplitPath)
{
delete[] this->SplitPath;
}
this->SplitLen = len;
delete[] this->SplitPath;
this->SplitPath = NULL;
this->SplitLen = len;
if (len && sp)
{
this->SplitPath = new int[len];
......
......@@ -114,22 +114,16 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
case 2:
PostQuitMessage (0);
if (theVTKApp)
{
delete theVTKApp;
theVTKApp = NULL;
}
delete theVTKApp;
theVTKApp = NULL;
break;
}
return 0;
case WM_DESTROY:
PostQuitMessage (0);
if (theVTKApp)
{
delete theVTKApp;
theVTKApp = NULL;
}
delete theVTKApp;
theVTKApp = NULL;
return 0;
}
return DefWindowProc (hwnd, message, wParam, lParam);
......
......@@ -241,10 +241,7 @@ void CvtkDLGDlg::OnDestroy()
if (this->pvtkActor2D) this->pvtkActor2D->Delete();
if (this->pvtkTextMapper) this->pvtkTextMapper->Delete();
if (this->pvtkMFCWindow)
{
delete this->pvtkMFCWindow;
}
delete this->pvtkMFCWindow;
CDialog::OnDestroy();
}
......
......@@ -67,17 +67,11 @@ vtkArrayCalculator::~vtkArrayCalculator()
this->FunctionParser->Delete();
this->FunctionParser = NULL;
if (this->Function)
{
delete [] this->Function;
this->Function = NULL;
}
delete [] this->Function;
this->Function = NULL;
if (this->ResultArrayName)
{
delete [] this->ResultArrayName;
this->ResultArrayName = NULL;
}
delete [] this->ResultArrayName;
this->ResultArrayName = NULL;
if (this->ScalarArrayNames)
{
......@@ -123,11 +117,8 @@ vtkArrayCalculator::~vtkArrayCalculator()
this->VectorVariableNames = NULL;
}
if (this->SelectedScalarComponents)
{
delete [] this->SelectedScalarComponents;
this->SelectedScalarComponents = NULL;
}
delete [] this->SelectedScalarComponents;
this->SelectedScalarComponents = NULL;
if (this->SelectedVectorComponents)
{
......@@ -162,11 +153,8 @@ vtkArrayCalculator::~vtkArrayCalculator()
this->CoordinateVectorVariableNames = NULL;
}
if (this->SelectedCoordinateScalarComponents)
{
delete [] this->SelectedCoordinateScalarComponents;
this->SelectedCoordinateScalarComponents = NULL;
}
delete [] this->SelectedCoordinateScalarComponents;
this->SelectedCoordinateScalarComponents = NULL;
if (this->SelectedCoordinateVectorComponents)
{
......@@ -193,11 +181,7 @@ void vtkArrayCalculator::SetResultArrayName(const char* name)
}
this->Modified();
if (this->ResultArrayName)
{
delete [] this->ResultArrayName;
this->ResultArrayName = NULL;
}
delete [] this->ResultArrayName;
this->ResultArrayName = new char [strlen(name)+1];
strcpy(this->ResultArrayName, name);
}
......@@ -613,11 +597,8 @@ void vtkArrayCalculator::SetFunction(const char* function)
this->Modified();
if (this->Function)
{
delete [] this->Function;
this->Function = NULL;
}
delete [] this->Function;
this->Function = NULL;
if (function)
{
......@@ -652,21 +633,14 @@ void vtkArrayCalculator::AddScalarArrayName(const char* arrayName,
this->ScalarVariableNames[i] = NULL;
tempComponents[i] = this->SelectedScalarComponents[i];
}
if (this->ScalarArrayNames)
{
delete [] this->ScalarArrayNames;
this->ScalarArrayNames = NULL;
}
if (this->ScalarVariableNames)
{
delete [] this->ScalarVariableNames;
this->ScalarVariableNames = NULL;
}
if (this->SelectedScalarComponents)
{
delete [] this->SelectedScalarComponents;
this->SelectedScalarComponents = NULL;
}
delete [] this->ScalarArrayNames;
this->ScalarArrayNames = NULL;
delete [] this->ScalarVariableNames;
this->ScalarVariableNames = NULL;
delete [] this->SelectedScalarComponents;
this->SelectedScalarComponents = NULL;
this->ScalarArrayNames = new char *[this->NumberOfScalarArrays + 1];
this->ScalarVariableNames = new char *[this->NumberOfScalarArrays + 1];
......@@ -729,21 +703,14 @@ void vtkArrayCalculator::AddVectorArrayName(const char* arrayName,
this->SelectedVectorComponents[i] = NULL;
}
if (this->VectorArrayNames)
{
delete [] this->VectorArrayNames;
this->VectorArrayNames = NULL;
}
if (this->VectorVariableNames)
{
delete [] this->VectorVariableNames;
this->VectorVariableNames = NULL;
}
if (this->SelectedVectorComponents)
{
delete [] this->SelectedVectorComponents;
this->SelectedVectorComponents = NULL;
}
delete [] this->VectorArrayNames;
this->VectorArrayNames = NULL;
delete [] this->VectorVariableNames;
this->VectorVariableNames = NULL;
delete [] this->SelectedVectorComponents;
this->SelectedVectorComponents = NULL;
this->VectorArrayNames = new char *[this->NumberOfVectorArrays + 1];
this->VectorVariableNames = new char *[this->NumberOfVectorArrays + 1];
......@@ -808,21 +775,14 @@ void vtkArrayCalculator::AddScalarVariable(const char* variableName,
this->ScalarVariableNames[i] = NULL;
tempComponents[i] = this->SelectedScalarComponents[i];
}
if (this->ScalarArrayNames)
{
delete [] this->ScalarArrayNames;
this->ScalarArrayNames = NULL;
}
if (this->ScalarVariableNames)
{
delete [] this->ScalarVariableNames;
this->ScalarVariableNames = NULL;
}
if (this->SelectedScalarComponents)
{
delete [] this->SelectedScalarComponents;
this->SelectedScalarComponents = NULL;
}
delete [] this->ScalarArrayNames;
this->ScalarArrayNames = NULL;
delete [] this->ScalarVariableNames;
this->ScalarVariableNames = NULL;
delete [] this->SelectedScalarComponents;
this->SelectedScalarComponents = NULL;
this->ScalarArrayNames = new char *[this->NumberOfScalarArrays + 1];
this->ScalarVariableNames = new char *[this->NumberOfScalarArrays + 1];
......@@ -886,21 +846,14 @@ void vtkArrayCalculator::AddVectorVariable(const char* variableName,
this->SelectedVectorComponents[i] = NULL;
}
if (this->VectorArrayNames)
{
delete [] this->VectorArrayNames;
this->VectorArrayNames = NULL;
}
if (this->VectorVariableNames)
{
delete [] this->VectorVariableNames;
this->VectorVariableNames = NULL;
}
if (this->SelectedVectorComponents)
{
delete [] this->SelectedVectorComponents;
this->SelectedVectorComponents = NULL;
}
delete [] this->VectorArrayNames;
this->VectorArrayNames = NULL;
delete [] this->VectorVariableNames;
this->VectorVariableNames = NULL;
delete [] this->SelectedVectorComponents;
this->SelectedVectorComponents = NULL;
this->VectorArrayNames = new char *[this->NumberOfVectorArrays + 1];
this->VectorVariableNames = new char *[this->NumberOfVectorArrays + 1];
......@@ -954,16 +907,12 @@ void vtkArrayCalculator::AddCoordinateScalarVariable(const char* variableName,
this->CoordinateScalarVariableNames[i] = NULL;
tempComponents[i] = this->SelectedCoordinateScalarComponents[i];
}
if (this->CoordinateScalarVariableNames)
{
delete [] this->CoordinateScalarVariableNames;
this->CoordinateScalarVariableNames = NULL;
}
if (this->SelectedCoordinateScalarComponents)
{
delete [] this->SelectedCoordinateScalarComponents;
this->SelectedCoordinateScalarComponents = NULL;
}
delete [] this->CoordinateScalarVariableNames;
this->CoordinateScalarVariableNames = NULL;
delete [] this->SelectedCoordinateScalarComponents;
this->SelectedCoordinateScalarComponents = NULL;
this->CoordinateScalarVariableNames =
new char *[this->NumberOfCoordinateScalarArrays + 1];
......@@ -1011,16 +960,11 @@ void vtkArrayCalculator::AddCoordinateVectorVariable(const char* variableName,
this->SelectedCoordinateVectorComponents[i] = NULL;
}
if (this->CoordinateVectorVariableNames)
{
delete [] this->CoordinateVectorVariableNames;
this->CoordinateVectorVariableNames = NULL;
}
if (this->SelectedCoordinateVectorComponents)
{
delete [] this->SelectedCoordinateVectorComponents;
this->SelectedCoordinateVectorComponents = NULL;
}
delete [] this->CoordinateVectorVariableNames;
this->CoordinateVectorVariableNames = NULL;
delete [] this->SelectedCoordinateVectorComponents;
this->SelectedCoordinateVectorComponents = NULL;
this->CoordinateVectorVariableNames =
new char *[this->NumberOfCoordinateVectorArrays + 1];
......
......@@ -303,10 +303,7 @@ vtkDataObjectGenerator::vtkDataObjectGenerator()
vtkDataObjectGenerator::~vtkDataObjectGenerator()
{
this->SetProgram(NULL);
if (this->Structure != NULL)
{
delete this->Structure;
}
delete this->Structure;
}
//----------------------------------------------------------------------------
......@@ -331,10 +328,7 @@ int vtkDataObjectGenerator::RequestDataObject(vtkInformation *,
return VTK_OK;
}
if (this->Structure != NULL)
{
delete this->Structure;
}
delete this->Structure;
this->Structure = vtkDataObjectGeneratorParseStructure(this->Program);
outData = this->CreateOutputDataObjects(this->Structure);
if (outData)
......
......@@ -100,51 +100,19 @@ vtkDataObjectToDataSetFilter::vtkDataObjectToDataSetFilter()
//----------------------------------------------------------------------------
vtkDataObjectToDataSetFilter::~vtkDataObjectToDataSetFilter()
{