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

Method Allocate

Common/Core/vtkBitArray.cxx:174–196  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Allocate memory for this array. Delete old storage only if necessary.

Source from the content-addressed store, hash-verified

172//------------------------------------------------------------------------------
173// Allocate memory for this array. Delete old storage only if necessary.
174vtkTypeBool vtkBitArray::Allocate(vtkIdType sz, vtkIdType vtkNotUsed(ext))
175{
176 if (sz > this->Size)
177 {
178 if (this->DeleteFunction)
179 {
180 this->DeleteFunction(this->Array);
181 }
182 this->Size = (sz > 0 ? sz : 1);
183 this->Array = new ValueType[(this->Size + 7) / 8];
184 if (this->Array == nullptr)
185 {
186 vtkErrorMacro(<< "Cannot allocate memory\n");
187 return 0;
188 }
189 this->DeleteFunction = ::operator delete[];
190 }
191
192 this->MaxId = -1;
193 this->DataChanged();
194
195 return 1;
196}
197
198//------------------------------------------------------------------------------
199// Release storage and reset array to initial state.

Callers 1

UpdateLookupMethod · 0.45

Calls 1

DataChangedMethod · 0.95

Tested by

no test coverage detected