Commit 7ab56ffe authored by Sean McBride's avatar Sean McBride

Removed unneeded checks for null before calling delete

Change-Id: I94935b6fe4d5e76e453507f9387b5ca357286cab
parent 3771e638
......@@ -1057,8 +1057,8 @@ vtkReebGraph::Implementation::vtkReebPath vtkReebGraph::Implementation::FindPath
while (pq.size())
{
vtkReebPath aux=pq.top();pq.pop();
if (aux.ArcTable) delete aux.ArcTable;
if (aux.NodeTable) delete aux.NodeTable;
delete aux.ArcTable;
delete aux.NodeTable;
}
if (Ntouch) free(Ntouch);
......
......@@ -199,7 +199,7 @@ void vtkCurvatures::GetMeanCurvature(vtkPolyData *mesh)
neighbour ->Delete();
if (meanCurvature) meanCurvature->Delete();
if (num_neighb) delete [] num_neighb;
delete [] num_neighb;
};
//--------------------------------------------
#define CLAMP_MACRO(v) ((v)<(-1) ? (-1) : (v) > (1) ? (1) : v)
......@@ -300,8 +300,8 @@ void vtkCurvatures::GetGaussCurvature(vtkPolyData *output)
vtkDebugMacro("Set Values of Gauss Curvature: Done");
/*******************************************************/
if (facet) facet->Delete();
if (K) delete [] K;
if (dA) delete [] dA;
delete [] K;
delete [] dA;
if (gaussCurvature) gaussCurvature->Delete();
/*******************************************************/
};
......
......@@ -42,10 +42,8 @@ vtkExtractUserDefinedPiece::vtkExtractUserDefinedPiece()
}
vtkExtractUserDefinedPiece::~vtkExtractUserDefinedPiece()
{
if (this->ConstantData){
delete [] (char *)this->ConstantData;
this->ConstantData = NULL;
}
delete [] (char *)this->ConstantData;
this->ConstantData = NULL;
}
void vtkExtractUserDefinedPiece::PrintSelf(ostream& os, vtkIndent indent)
{
......
......@@ -52,8 +52,7 @@ QVTKGraphicsItem::QVTKGraphicsItem(QGLContext* ctx, QGraphicsItem* p)
QVTKGraphicsItem::~QVTKGraphicsItem()
{
if(mFBO)
delete mFBO;
delete mFBO;
}
void QVTKGraphicsItem::SetRenderWindow(vtkGenericOpenGLRenderWindow* win)
......@@ -118,8 +117,7 @@ void QVTKGraphicsItem::MakeCurrent()
QSize sz = this->size().toSize();
if(!mFBO || sz != mFBO->size())
{
if(mFBO)
delete mFBO;
delete mFBO;
if(!sz.isEmpty())
mFBO = new QGLFramebufferObject(sz, QGLFramebufferObject::Depth);
......
......@@ -4954,8 +4954,7 @@ unsigned long vtkExodusIIReader::GetMetadataMTime()
if ( fname && this->propName && !strcmp( fname, this->propName ) ) \
return; \
modified = 1; \
if ( this->propName ) \
delete [] this->propName; \
delete [] this->propName; \
if ( fname ) \
{ \
size_t fnl = strlen( fname ) + 1; \
......
......@@ -424,8 +424,8 @@ int vtkChacoReader::ReadFile(vtkUnstructuredGrid* output)
if (!memoryOK)
{
vtkErrorMacro(<< "ReadFile memory allocation failure");
if (x) delete [] x;
if (y) delete [] y;
delete [] x;
delete [] y;
return 0;
}
......@@ -435,9 +435,9 @@ int vtkChacoReader::ReadFile(vtkUnstructuredGrid* output)
if (rc == 0)
{
if (x) delete [] x;
if (y) delete [] y;
if (z) delete [] z;
delete [] x;
delete [] y;
delete [] z;
return 0;
}
......@@ -465,9 +465,9 @@ int vtkChacoReader::ReadFile(vtkUnstructuredGrid* output)
output->SetPoints(ptarray);
if (x) delete [] x;
if (y) delete [] y;
if (z) delete [] z;
delete [] x;
delete [] y;
delete [] z;
ptarray->Delete();
// Read in cell topology and possibly cell and point weights.
......
......@@ -180,8 +180,7 @@ int vtkOggTheoraWriterInternal::Start()
// the stride is in bytes
this->thImage[i].stride = this->thImage[i].width*sizeof(unsigned char);
// make sure there's nothing left laying around...
if (this->thImage[i].data)
delete[] this->thImage[i].data;
delete[] this->thImage[i].data;
// allocate the image plane
size_t siz = this->thImage[i].width * this->thImage[i].height;
this->thImage[i].data = new unsigned char[siz];
......
......@@ -233,8 +233,8 @@ void vtkPLYWriter::WriteData()
}
}//for all polygons
if ( pointColors ) {delete [] pointColors;}
if ( cellColors ) {delete [] cellColors;}
delete [] pointColors;
delete [] cellColors;
// close the PLY file
vtkPLY::ply_close (ply);
......
......@@ -286,8 +286,7 @@ int vtkPExodusIIReader::RequestInformation(
char* nm =
new char[strlen( this->FilePattern ) + strlen( this->FilePrefix ) + 20];
sprintf( nm, this->FilePattern, this->FilePrefix, this->FileRange[0] );
if ( this->FileName )
delete [] this->FileName;
delete [] this->FileName;
this->FileName = nm;
//this->Superclass::SetFileName( nm ); // XXX Bad set
//delete [] nm;
......@@ -915,10 +914,8 @@ int vtkPExodusIIReader::DeterminePattern( const char* file )
//this->SetFilePattern( pattern ); // XXX Bad set
//this->SetFilePrefix( file ); // XXX Bad set
//this->SetFileRange( min, max ); // XXX Bad set
if ( this->FilePattern )
delete [] this->FilePattern;
if ( this->FilePrefix )
delete [] this->FilePrefix;
delete [] this->FilePattern;
delete [] this->FilePrefix;
this->FilePattern = vtksys::SystemTools::DuplicateString( pattern );
this->FilePrefix = vtksys::SystemTools::DuplicateString( file );
this->FileRange[0] = min;
......@@ -1008,10 +1005,8 @@ int vtkPExodusIIReader::DeterminePattern( const char* file )
//this->SetFilePattern( pattern ); // XXX Bad set
//this->SetFilePrefix( prefix ); // XXX Bad set
//delete [] prefix;
if ( this->FilePattern )
delete [] this->FilePattern;
if ( this->FilePrefix )
delete [] this->FilePrefix;
delete [] this->FilePattern;
delete [] this->FilePrefix;
this->FilePattern = vtksys::SystemTools::DuplicateString( pattern );
this->FilePrefix = vtksys::SystemTools::DuplicateString(prefix.c_str());
......@@ -1604,10 +1599,8 @@ void vtkPExodusIIReader::Broadcast( vtkMultiProcessController* ctrl )
else
{
std::vector<char> tmp;
if ( this->FilePattern )
delete [] this->FilePattern;
if ( this->FilePrefix )
delete [] this->FilePrefix;
delete [] this->FilePattern;
delete [] this->FilePrefix;
//this->SetFilePattern( BroadcastRecvString( ctrl, tmp ) ? &tmp[0] : 0 ); // XXX Bad set
//this->SetFilePrefix( BroadcastRecvString( ctrl, tmp ) ? &tmp[0] : 0 ); // XXX Bad set
this->FilePattern = BroadcastRecvString( ctrl, tmp ) ? vtksys::SystemTools::DuplicateString( &tmp[0] ) : 0;
......
......@@ -106,16 +106,11 @@ vtkVPICReader::~vtkVPICReader()
}
this->PointDataArraySelection->Delete();
if (this->vpicData)
delete this->vpicData;
if (this->VariableName)
delete [] this->VariableName;
if (this->VariableStruct)
delete [] this->VariableStruct;
if (this->TimeSteps)
delete [] this->TimeSteps;
if (this->dataLoaded)
delete [] this->dataLoaded;
delete this->vpicData;
delete [] this->VariableName;
delete [] this->VariableStruct;
delete [] this->TimeSteps;
delete [] this->dataLoaded;
if (this->exchanger)
delete this->exchanger;
......@@ -351,8 +346,7 @@ int vtkVPICReader::RequestInformation(
int decomposition[DIMENSION];
this->vpicData->getDecomposition(decomposition);
if (this->exchanger)
delete this->exchanger;
delete this->exchanger;
this->exchanger = new GridExchange
(this->Rank, this->TotalRank, decomposition,
......
......@@ -45,10 +45,10 @@ vtkXMLPDataWriter::vtkXMLPDataWriter()
//----------------------------------------------------------------------------
vtkXMLPDataWriter::~vtkXMLPDataWriter()
{
if(this->PathName) { delete [] this->PathName; }
if(this->FileNameBase) { delete [] this->FileNameBase; }
if(this->FileNameExtension) { delete [] this->FileNameExtension; }
if(this->PieceFileNameExtension) { delete [] this->PieceFileNameExtension; }
delete [] this->PathName;
delete [] this->FileNameBase;
delete [] this->FileNameExtension;
delete [] this->PieceFileNameExtension;
this->ProgressObserver->Delete();
}
......@@ -234,8 +234,7 @@ void vtkXMLPDataWriter::SplitFileName()
// "begin" now points at the beginning of the file name.
// Look for the first "." to pull off the longest extension.
if(this->FileNameExtension)
{ delete [] this->FileNameExtension; this->FileNameExtension = 0; }
delete [] this->FileNameExtension; this->FileNameExtension = 0;
for(s=begin; s != end; ++s) { if(*s == '.') { break; } }
if(s < end)
{
......
......@@ -81,8 +81,8 @@ vtkXMLDataParser::~vtkXMLDataParser()
delete [] this->OpenElements;
this->InlineDataStream->Delete();
this->AppendedDataStream->Delete();
if(this->BlockCompressedSizes) { delete [] this->BlockCompressedSizes; }
if(this->BlockStartOffsets) { delete [] this->BlockStartOffsets; }
delete [] this->BlockCompressedSizes;
delete [] this->BlockStartOffsets;
this->SetCompressor(0);
if(this->AsciiDataBuffer) { this->FreeAsciiBuffer(); }
}
......
......@@ -40,11 +40,11 @@ public:
this->Bounds[4] = 0; this->Bounds[5] = 256; };
~vtkColorQuantizeNode()
{ if ( this->Histogram[0] ) { delete []this->Histogram[0]; }
if ( this->Histogram[1] ) { delete []this->Histogram[1]; }
if ( this->Histogram[2] ) { delete []this->Histogram[2]; }
if ( this->Child1 ) { delete this->Child1; }
if ( this->Child2 ) { delete this->Child2; } };
{ delete []this->Histogram[0];
delete []this->Histogram[1];
delete []this->Histogram[2];
delete this->Child1;
delete this->Child2; };
void SetImageExtent( int v[6] )
{ memcpy( this->ImageExtent, v, 6*sizeof(int) ); };
......
......@@ -116,7 +116,7 @@ void vtkAttributeClustering2DLayoutStrategy::SetVertexAttribute(const char* att)
// except for the call to Initialize at the end :)
if ( this->VertexAttribute == NULL && att == NULL) { return;}
if ( this->VertexAttribute && att && (!strcmp(this->VertexAttribute,att))) { return;}
if (this->VertexAttribute) { delete [] this->VertexAttribute; }
delete [] this->VertexAttribute;
if (att)
{
size_t n = strlen(att) + 1;
......
......@@ -110,8 +110,8 @@ void vtkForceDirectedLayoutStrategy::Initialize()
}
}
if (this->v) delete[] this->v;
if (this->e) delete[] this->e;
delete[] this->v;
delete[] this->e;
this->v = new vtkLayoutVertex[numVertices];
this->e = new vtkLayoutEdge[numEdges];
......
......@@ -78,7 +78,7 @@ void vtkGraphLayoutStrategy::SetEdgeWeightField(const char* weights)
// except for the call to Initialize at the end :)
if ( this->EdgeWeightField == NULL && weights == NULL) { return;}
if ( this->EdgeWeightField && weights && (!strcmp(this->EdgeWeightField,weights))) { return;}
if (this->EdgeWeightField) { delete [] this->EdgeWeightField; }
delete [] this->EdgeWeightField;
if (weights)
{
size_t n = strlen(weights) + 1;
......
......@@ -801,7 +801,7 @@ vtkLabeledDataMapper::SetFieldDataName(const char *arrayName)
if ( this->FieldDataName == NULL && arrayName == NULL) { return; }
if ( this->FieldDataName && arrayName && (!strcmp(this->FieldDataName,arrayName))) { return;}
if (this->FieldDataName) { delete [] this->FieldDataName; }
delete [] this->FieldDataName;
if (arrayName)
{
this->FieldDataName = new char[strlen(arrayName)+1];
......
......@@ -68,8 +68,7 @@ vtkOpenGLRenderWindow::vtkOpenGLRenderWindow()
this->MultiSamples = vtkOpenGLRenderWindowGlobalMaximumNumberOfMultiSamples;
this->TextureResourceIds = vtkIdList::New();
if ( this->WindowName )
delete [] this->WindowName;
delete [] this->WindowName;
this->WindowName = new char[strlen("Visualization Toolkit - OpenGL")+1];
strcpy( this->WindowName, "Visualization Toolkit - OpenGL" );
......
......@@ -278,15 +278,15 @@ vtkHAVSVolumeMapper::vtkHAVSVolumeMapper()
//----------------------------------------------------------------------------
vtkHAVSVolumeMapper::~vtkHAVSVolumeMapper()
{
if (this->Vertices) { delete [] this->Vertices; }
if (this->Scalars) { delete [] this->Scalars; }
if (this->Triangles) { delete [] this->Triangles; }
if (this->BoundaryTriangles) { delete [] this->BoundaryTriangles; }
if (this->InternalTriangles) { delete [] this->InternalTriangles; }
if (this->SortedFaces) { delete [] this->SortedFaces; }
if (this->RadixTemp) { delete [] this->RadixTemp; }
if (this->Centers) { delete [] this->Centers; }
if (this->TransferFunction) { delete [] this->TransferFunction; }
delete [] this->Vertices;
delete [] this->Scalars;
delete [] this->Triangles;
delete [] this->BoundaryTriangles;
delete [] this->InternalTriangles;
delete [] this->SortedFaces;
delete [] this->RadixTemp;
delete [] this->Centers;
delete [] this->TransferFunction;
}
//----------------------------------------------------------------------------
......@@ -318,13 +318,13 @@ void vtkHAVSVolumeMapper::InitializePrimitives(vtkVolume *vol)
return;
}
if (this->Vertices) { delete [] this->Vertices; }
if (this->Triangles) { delete [] this->Triangles; }
if (this->BoundaryTriangles) { delete [] this->BoundaryTriangles; }
if (this->InternalTriangles) { delete [] this->InternalTriangles; }
if (this->SortedFaces) { delete [] this->SortedFaces; }
if (this->RadixTemp) { delete [] this->RadixTemp; }
if (this->Centers) { delete [] this->Centers; }
delete [] this->Vertices;
delete [] this->Triangles;
delete [] this->BoundaryTriangles;
delete [] this->InternalTriangles;
delete [] this->SortedFaces;
delete [] this->RadixTemp;
delete [] this->Centers;
// Extract the triangles from the tetrahedra
......
......@@ -92,8 +92,8 @@ vtkLinearRayIntegratorTransferFunction::vtkLinearRayIntegratorTransferFunction()
vtkLinearRayIntegratorTransferFunction::~vtkLinearRayIntegratorTransferFunction()
{
if (this->ControlPoints) delete[] this->ControlPoints;
if (this->Colors) delete[] this->Colors;
delete[] this->ControlPoints;
delete[] this->Colors;
}
static const double huebends[6] = {
......@@ -219,8 +219,8 @@ void vtkLinearRayIntegratorTransferFunction::GetTransferFunction(
}
// Now record control points and colors.
if (this->ControlPoints) delete[] this->ControlPoints;
if (this->Colors) delete[] this->Colors;
delete[] this->ControlPoints;
delete[] this->Colors;
this->NumControlPoints = static_cast<int>(cpset.size());
this->ControlPoints = new double[this->NumControlPoints];
this->Colors = new acolor[this->NumControlPoints];
......@@ -272,8 +272,8 @@ void vtkLinearRayIntegratorTransferFunction::GetTransferFunction(
}
// Now record control points and colors.
if (this->ControlPoints) delete[] this->ControlPoints;
if (this->Colors) delete[] this->Colors;
delete[] this->ControlPoints;
delete[] this->Colors;
this->NumControlPoints = static_cast<int>(cpset.size());
this->ControlPoints = new double[this->NumControlPoints];
this->Colors = new acolor[this->NumControlPoints];
......
......@@ -281,26 +281,13 @@ vtkParallelCoordinatesRepresentation::vtkParallelCoordinatesRepresentation()
//------------------------------------------------------------------------------
vtkParallelCoordinatesRepresentation::~vtkParallelCoordinatesRepresentation()
{
if (I)
delete I;
if (this->Maxs)
delete [] this->Maxs;
if (this->Mins)
delete [] this->Mins;
if (this->MaxOffsets)
delete [] this->MaxOffsets;
if (this->MinOffsets)
delete [] this->MinOffsets;
if (this->Axes)
delete [] this->Axes;
if (this->Xs)
delete [] this->Xs;
delete I;
delete [] this->Maxs;
delete [] this->Mins;
delete [] this->MaxOffsets;
delete [] this->MinOffsets;
delete [] this->Axes;
delete [] this->Xs;
this->SetInternalHoverText(0);
}
......@@ -860,12 +847,12 @@ int vtkParallelCoordinatesRepresentation::UpdatePlotProperties(vtkStringArray* i
// Clear out all of the arrays and intialize them to defaults where appropriate.
int vtkParallelCoordinatesRepresentation::ReallocateInternals()
{
if (this->Maxs) delete [] this->Maxs;
if (this->Mins) delete [] this->Mins;
if (this->MaxOffsets) delete [] this->MaxOffsets;
if (this->MinOffsets) delete [] this->MinOffsets;
if (this->Axes) delete [] this->Axes;
if (this->Xs) delete [] this->Xs;
delete [] this->Maxs;
delete [] this->Mins;
delete [] this->MaxOffsets;
delete [] this->MinOffsets;
delete [] this->Axes;
delete [] this->Xs;
this->Maxs = new double[this->NumberOfAxes];
this->Mins = new double[this->NumberOfAxes];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment