MCPcopy Create free account
hub / github.com/Kitware/VTK / Resize

Method Resize

Common/Core/vtkVariantArray.cxx:620–667  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

618
619//------------------------------------------------------------------------------
620vtkTypeBool vtkVariantArray::Resize(vtkIdType sz)
621{
622 ValueType* newArray;
623 vtkIdType newSize = sz * this->GetNumberOfComponents();
624
625 if (newSize == this->Size)
626 {
627 return 1;
628 }
629
630 if (newSize <= 0)
631 {
632 this->Initialize();
633 return 1;
634 }
635
636 newArray = new ValueType[newSize];
637 if (!newArray)
638 {
639 vtkErrorMacro(<< "Cannot allocate memory\n");
640 return 0;
641 }
642
643 if (this->Array)
644 {
645 vtkIdType numCopy = (newSize < this->Size ? newSize : this->Size);
646
647 for (vtkIdType i = 0; i < numCopy; ++i)
648 {
649 newArray[i] = this->Array[i];
650 }
651
652 if (this->DeleteFunction)
653 {
654 this->DeleteFunction(this->Array);
655 }
656 }
657
658 if (newSize < this->Size)
659 {
660 this->MaxId = newSize - 1;
661 }
662 this->Size = newSize;
663 this->Array = newArray;
664 this->DeleteFunction = DefaultDeleteFunction;
665 this->DataChanged();
666 return 1;
667}
668
669//------------------------------------------------------------------------------
670void vtkVariantArray::SetVoidArray(void* arr, vtkIdType size, int save)

Callers

nothing calls this directly

Calls 3

InitializeMethod · 0.95
DataChangedMethod · 0.95
GetNumberOfComponentsMethod · 0.45

Tested by

no test coverage detected