carb::reallocate
Defined in carb/Memory.h
- 
inline void *carb::reallocate(void *p, size_t size, size_t align = 0) noexcept
- Reallocates a block of memory previously allocated with allocate(). - This function changes the size of the memory block pointed to by - pto- sizebytes with- alignalignment. The contents are unchanged from the start of the memory block up to the minimum of the old size and- size. If- sizeis larger than the old size, the added memory is not initialized. If- pis- nullptr, the call is equivalent to- allocate(size, align); if- sizeis- 0and- pis not- nullptr, the call is equivalent to- deallocate(p). Unless- pis- nullptr, it must have been retrieved by an earlier call to allocate() or reallocate(). If the memory region was moved in order to resize it,- pwill be freed as with- deallocate(p).- Note - Any plugin (or the executable) may allocate the memory and a different plugin (or the executable) may deallocate or reallocate it. - Note - If carb.dll/libcarb.so is not loaded, this function will always return - pwithout side-effects.- Parameters
- p – The block of memory previously returned from allocate() or reallocate() if resizing is resizing is desired. If - nullptris passed as this parameter, the call behaves as if- allocate(size, align)was called.
- size – The size of the memory block requested, in bytes. See above for further explanation. 
- align – The minimum alignment (in bytes) of the memory block requested. Must be a power of two. Values less than - sizeof(size_t)are ignored. Changing the alignment from a previous allocation is undefined behavior.- 0indicates to use default system alignment (typically- 2 * sizeof(void*)).
 
- Returns
- A pointer to a block of memory of - sizebytes with minimum alignment- align, unless an error occurs in which case- nullptris returned. If- pis- nullptrand- sizeis- 0then- nullptris also returned.