21 VTK_ABI_NAMESPACE_BEGIN
22 template <
class ScalarTypeT>
99 void operator=(
const vtkBuffer&) =
delete;
102 template <
class ScalarT>
108 template <
class ScalarT>
116 template <
typename ScalarT>
119 if (this->Pointer != array)
121 if (this->DeleteFunction)
123 this->DeleteFunction(this->Pointer);
125 this->Pointer = array;
130 template <
typename ScalarT>
133 this->MallocFunction = mallocFunction;
136 template <
typename ScalarT>
139 this->ReallocFunction = reallocFunction;
143 template <
typename ScalarT>
148 this->DeleteFunction =
nullptr;
152 this->DeleteFunction = deleteFunction;
157 template <
typename ScalarT>
161 this->SetBuffer(
nullptr, 0);
165 if (this->MallocFunction)
175 this->SetBuffer(newArray, size);
176 if (!this->MallocFunction)
178 this->DeleteFunction = free;
188 template <
typename ScalarT>
193 return this->Allocate(0);
196 if (this->Pointer && this->DeleteFunction != free)
199 bool forceFreeFunction =
false;
200 if (this->MallocFunction)
203 if (this->MallocFunction == malloc)
211 forceFreeFunction =
true;
222 std::copy(this->Pointer, this->Pointer + (std::min)(this->Size, newsize), newArray);
224 this->SetBuffer(newArray, newsize);
225 if (!this->MallocFunction || forceFreeFunction)
227 this->DeleteFunction = free;
235 if (this->ReallocFunction)
238 this->ReallocFunction(this->Pointer, newsize *
sizeof(
ScalarType)));
248 this->Pointer = newArray;
249 this->Size = newsize;
254 VTK_ABI_NAMESPACE_END
static vtkBuffer< ScalarTypeT > * New()
static vtkBuffer< ScalarTypeT > * ExtendedNew()
void SetReallocFunction(vtkReallocingFunction reallocFunction=realloc)
Set the realloc function to be used when allocating space inside this object.
abstract base class for most VTK objects
vtkFreeingFunction DeleteFunction
void(* vtkFreeingFunction)(void *)
vtkIdType GetSize() const
Return the number of elements the current buffer can hold.
A class to help modify and restore the global UsingMemkind state, like SetUsingMemkind(newValue), but safer.
void SetMallocFunction(vtkMallocingFunction mallocFunction=malloc)
Set the malloc function to be used when allocating space inside this object.
static vtkReallocingFunction GetCurrentReallocFunction()
void SetFreeFunction(bool noFreeFunction, vtkFreeingFunction deleteFunction=free)
Set the free function to be used when releasing this object.
vtkMallocingFunction MallocFunction
internal storage class used by vtkSOADataArrayTemplate, vtkAOSDataArrayTemplate, and others...
ScalarType * GetBuffer()
Access the buffer as a scalar pointer.
void SetBuffer(ScalarType *array, vtkIdType size)
Set the memory buffer that this vtkBuffer object will manage.
void *(* vtkMallocingFunction)(size_t)
#define VTK_STANDARD_NEW_BODY(thisClass)
bool Reallocate(vtkIdType newsize)
Allocate a new buffer that holds newsize elements.
bool Allocate(vtkIdType size)
Allocate a new buffer that holds size elements.
static vtkFreeingFunction GetCurrentFreeFunction()
const ScalarType * GetBuffer() const
void *(* vtkReallocingFunction)(void *, size_t)
vtkTemplateTypeMacro(vtkBuffer< ScalarTypeT >, vtkObject)
vtkReallocingFunction ReallocFunction
static vtkMallocingFunction GetCurrentMallocFunction()