BlockAllocator#
Fully qualified name: omni::structuredlog::BlockAllocator
Defined in omni/structuredlog/JsonTree.h
-
class BlockAllocator : public omni::structuredlog::Allocator#
An implementation of Allocator which will just allocate from a preallocated block of memory and never deallocate memory until the full preallocated block is freed.
This is useful for something like a structured log event, where the required size of the tree can be preallocated.
Public Functions
-
inline BlockAllocator(void *block, size_t len)#
Create the allocator from a preallocated block.
- Parameters:
block – [in] The block of memory to allocate from.
len – [in] The length of
block
in bytes.
-
inline virtual void *alloc(size_t size) override#
Allocated memory.
Remark
This should be overwritten by custom memory allocators to use another allocation mechanism.
- Parameters:
size – [in] The number of bytes to allocate.
- Returns:
The allocated memory.
- Returns:
nullptr if memory was not available.
Public Static Functions
-
static inline size_t fixupAlignment(size_t size)#
Round a size up to be aligned to kAlignment.
- Parameters:
size – [in] The size to align.
- Returns:
size
rounded up to the next multiple of kAlignment.
Public Static Attributes
-
static constexpr size_t kAlignment = alignof(void*)#
The alignment that each allocation must be.
-
inline BlockAllocator(void *block, size_t len)#