carbReallocate
Defined in carb/Memory.h
-
void *carbReallocate(void *p, size_t size, size_t align)
Internal function used by all other allocation functions.
This function is the entry point into
carb.dll
/libcarb.so
for carb::allocate(), carb::deallocate(), and carb::reallocate(). There are four modes to this function:If
p
isnullptr
andsize
is0
, no action is taken andnullptr
is returned.If
p
is notnullptr
andsize
is0
, the given pointer is deallocated andnullptr
is returned.If
p
isnullptr
andsize
is non-zero, memory of the requestedsize
and alignment specified byalign
is allocated and returned. If an allocation error occurs,nullptr
is returned.If
p
is notnullptr
andsize
is non-zero, the memory is reallocated and copied (as if bystd::memcpy
) to the new memory block, which is returned. Ifp
can be resized in situ, the samep
value is returned. If an error occurs,nullptr
is returned.
Note
Using this function requires explicitly linking with
carb.dll
/libcarb.so
if CARB_REQUIRE_LINKED is1
. Otherwise, the caller must ensure thatcarb.dll
/libcarb.so
is already loaded before calling this function. Use in situations where the Carbonite Framework is already loaded (i.e. plugins) does not require explicitly linking against Carbonite as this function will be found dynamically at runtime.Warning
Do not call this function directly. Instead call carb::allocate(), carb::deallocate(), or carb::reallocate()
- Parameters
p – The pointer to re-allocate or free. May be
nullptr
. See explanation above.size – The requested size of the memory region in bytes. See explanation above.
align – The requested alignment of the memory region in bytes. Must be a power of two. See explanation above.
- Returns
Allocated memory, or
nullptr
upon deallocation, ornullptr
on allocation when an error occurs.