Commit 5b770c56 authored by Brad King's avatar Brad King

ENH: Reimplemented Allocate method for exception safety. Fix suggested on...

ENH: Reimplemented Allocate method for exception safety.  Fix suggested on users list by Alain Coron.
parent 60a00ac7
......@@ -78,6 +78,8 @@ void vtkDataArrayTemplate<T>::SetArray(T* array, vtkIdType size, int save)
template <class T>
int vtkDataArrayTemplate<T>::Allocate(vtkIdType sz, vtkIdType)
{
this->MaxId = -1;
if(sz > this->Size)
{
if(this->Array && !this->SaveUserArray)
......@@ -85,17 +87,19 @@ int vtkDataArrayTemplate<T>::Allocate(vtkIdType sz, vtkIdType)
delete [] this->Array;
}
this->Size = ( sz > 0 ? sz : 1);
this->Array = new T[this->Size];
this->Array = 0;
this->Size = 0;
this->SaveUserArray = 0;
int newSize = (sz > 0 ? sz : 1);
this->Array = new T[newSize];
if(!this->Array)
{
return 0;
}
this->SaveUserArray = 0;
this->Size = newSize;
}
this->MaxId = -1;
return 1;
}
......
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