A BlockAllocator that allocates the blocks from a fixed size storage.
More...
#include <wpi/memory/static_allocator.hpp>
A BlockAllocator that allocates the blocks from a fixed size storage.
It works on a static_allocator_storage and uses it for all allocations, deallocations are only allowed in reversed order which is guaranteed by memory_arena.
- Note
- It is not allowed to share an static_allocator_storage between multiple static_allocator objects.
◆ static_block_allocator() [1/2]
template<std::size_t Size>
wpi::memory::static_block_allocator::static_block_allocator |
( |
std::size_t | block_size, |
|
|
static_allocator_storage< Size > & | storage ) |
|
inlinenoexcept |
- Effects:
- Creates it by passing it the block size and a static_allocator_storage by reference. It will take the address of the storage and use it to allocate
block_size'd
blocks.
- Requires:
- The storage object must live as long as the allocator object. It must not be shared between multiple allocators, i.e. the object must not have been passed to a constructor before. The size of the static_allocator_storage must be a multiple of the (non-null) block size.
◆ ~static_block_allocator()
wpi::memory::static_block_allocator::~static_block_allocator |
( |
| ) |
|
|
defaultnoexcept |
◆ static_block_allocator() [2/2]
- Effects:
- Moves the block allocator, it transfers ownership over the static_allocator_storage. This does not invalidate any memory blocks.
◆ allocate_block()
memory_block wpi::memory::static_block_allocator::allocate_block |
( |
| ) |
|
- Effects:
- Allocates a new block by returning the next_block_size() bytes.
- Returns:
- The new memory block.
◆ deallocate_block()
void wpi::memory::static_block_allocator::deallocate_block |
( |
memory_block | block | ) |
|
|
noexcept |
- Effects:
- Deallocates the last memory block by marking the block as free again. This block will be returned again by the next call to allocate_block().
- Requires:
block
must be the current top block of the memory, this is guaranteed by memory_arena.
◆ next_block_size()
std::size_t wpi::memory::static_block_allocator::next_block_size |
( |
| ) |
const |
|
inlinenoexcept |
- Returns:
- The next block size, this is the size passed to the constructor.
◆ operator=()
◆ swap
The documentation for this class was generated from the following file: