iceoryx
iceoryx copied to clipboard
Introduce ManagedMemory struct to simplify allocator usage
Brief feature description
Using the BumpAllocator
usually follows the pattern
uint8_t memory[MEMORY_SIZE]; // create some memory
BumpAllocator memoryAllocator{memory, MEMORY_SIZE}; // use the allocator
The same is likely to be true for future allocators. This could be combined in a struct like
template<uint64_t MEMORY_SIZE>
class ManagedMemory {
public:
ManagedMemory() : allocator{&this->memory, MEMORY_SIZE} {}
BumpAllocator& allocator();
private:
uint8_t memory[MEMORY_SIZE];
BumpAllocator allocator;
}