24VTK_ABI_NAMESPACE_BEGIN
25template <
class ScalarTypeT>
102 void operator=(
const vtkBuffer&) =
delete;
105template <
class ScalarT>
111template <
class ScalarT>
119template <
typename ScalarT>
122 if (this->Pointer != array)
124 if (this->DeleteFunction)
126 this->DeleteFunction(this->Pointer);
128 this->Pointer = array;
133template <
typename ScalarT>
136 this->MallocFunction = mallocFunction;
139template <
typename ScalarT>
142 this->ReallocFunction = reallocFunction;
146template <
typename ScalarT>
151 this->DeleteFunction =
nullptr;
155 this->DeleteFunction = deleteFunction;
160template <
typename ScalarT>
164 this->SetBuffer(
nullptr, 0);
168 if (this->MallocFunction)
178 this->SetBuffer(newArray, size);
179 if (!this->MallocFunction)
181 this->DeleteFunction = free;
191template <
typename ScalarT>
196 return this->Allocate(0);
199 if (this->Pointer && this->DeleteFunction != free)
202 bool forceFreeFunction =
false;
203 if (this->MallocFunction)
206 if (this->MallocFunction == malloc)
214 forceFreeFunction =
true;
225 std::copy(this->Pointer, this->Pointer + (std::min)(this->Size, newsize), newArray);
227 this->SetBuffer(newArray, newsize);
228 if (!this->MallocFunction || forceFreeFunction)
230 this->DeleteFunction = free;
238 if (this->ReallocFunction)
241 this->ReallocFunction(this->Pointer, newsize *
sizeof(
ScalarType)));
251 this->Pointer = newArray;
252 this->Size = newsize;
internal storage class used by vtkSOADataArrayTemplate, vtkAOSDataArrayTemplate, and others.
bool Reallocate(vtkIdType newsize)
Allocate a new buffer that holds newsize elements.
ScalarType * GetBuffer()
Access the buffer as a scalar pointer.
vtkFreeingFunction DeleteFunction
vtkMallocingFunction MallocFunction
const ScalarType * GetBuffer() const
void SetReallocFunction(vtkReallocingFunction reallocFunction=realloc)
Set the realloc function to be used when allocating space inside this object.
static vtkBuffer< ScalarTypeT > * ExtendedNew()
void SetMallocFunction(vtkMallocingFunction mallocFunction=malloc)
Set the malloc function to be used when allocating space inside this object.
vtkIdType GetSize() const
Return the number of elements the current buffer can hold.
vtkTemplateTypeMacro(vtkBuffer< ScalarTypeT >, vtkObject)
void SetFreeFunction(bool noFreeFunction, vtkFreeingFunction deleteFunction=free)
Set the free function to be used when releasing this object.
vtkReallocingFunction ReallocFunction
bool Allocate(vtkIdType size)
Allocate a new buffer that holds size elements.
static vtkBuffer< ScalarTypeT > * New()
void SetBuffer(ScalarType *array, vtkIdType size)
Set the memory buffer that this vtkBuffer object will manage.
A class to help modify and restore the global UsingMemkind state, like SetUsingMemkind(newValue),...
static vtkFreeingFunction GetCurrentFreeFunction()
static vtkMallocingFunction GetCurrentMallocFunction()
static vtkReallocingFunction GetCurrentReallocFunction()
abstract base class for most VTK objects
void *(* vtkMallocingFunction)(size_t)
void *(* vtkReallocingFunction)(void *, size_t)
void(* vtkFreeingFunction)(void *)
#define VTK_STANDARD_NEW_BODY(thisClass)