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.sofor carb::allocate(), carb::deallocate(), and carb::reallocate(). There are four modes to this function:If
pisnullptrandsizeis0, no action is taken andnullptris returned.If
pis notnullptrandsizeis0, the given pointer is deallocated andnullptris returned.If
pisnullptrandsizeis non-zero, memory of the requestedsizeand alignment specified byalignis allocated and returned. If an allocation error occurs,nullptris returned.If
pis notnullptrandsizeis non-zero, the memory is reallocated and copied (as if bystd::memcpy) to the new memory block, which is returned. Ifpcan be resized in situ, the samepvalue is returned. If an error occurs,nullptris returned.
Note
Using this function requires explicitly linking with
carb.dll/libcarb.soif CARB_REQUIRE_LINKED is1. Otherwise, the caller must ensure thatcarb.dll/libcarb.sois 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
nullptrupon deallocation, ornullptron allocation when an error occurs.