carb::allocate
Defined in carb/Memory.h
-
inline void *carb::allocate(size_t size, size_t align = 0) noexcept
Allocates a block of memory.
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
nullptr
.- Parameters
size – The size of the memory block requested, in bytes. Specifying ‘0’ will return a valid pointer that can be passed to deallocate but cannot be used to store any information.
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.0
indicates to use default system alignment (typically2 * sizeof(void*)
).
- Returns
A non-
nullptr
memory block ofsize
bytes with minimum alignmentalign
. If an error occurred, or memory could not be allocated,nullptr
is returned. The memory is not initialized.