A stateful RawAllocator that uses a fixed sized storage for the allocations.
More...
#include <wpi/memory/static_allocator.hpp>
A stateful RawAllocator that uses a fixed sized storage for the allocations.
It works on a static_allocator_storage and uses its memory for all allocations. Deallocations are not supported, memory cannot be marked as freed.
- Note
- It is not allowed to share an static_allocator_storage between multiple static_allocator objects.
◆ is_stateful
◆ static_allocator()
template<std::size_t Size>
- Effects:
- Creates it by passing it a static_allocator_storage by reference. It will take the address of the storage and use its memory for the allocation.
- 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.
◆ allocate_node()
void * wpi::memory::static_allocator::allocate_node |
( |
std::size_t | size, |
|
|
std::size_t | alignment ) |
- Effects:
- A RawAllocator allocation function. It uses the specified static_allocator_storage.
- Returns:
- A pointer to a node, it will never be
nullptr
.
- Throws:
- An exception of type out_of_memory or whatever is thrown by its handler if the storage is exhausted.
◆ deallocate_node()
void wpi::memory::static_allocator::deallocate_node |
( |
void * | , |
|
|
std::size_t | , |
|
|
std::size_t | ) |
|
inlinenoexcept |
- Effects:
- A RawAllocator deallocation function. It does nothing, deallocation is not supported by this allocator.
◆ max_alignment()
std::size_t wpi::memory::static_allocator::max_alignment |
( |
| ) |
const |
|
inlinenoexcept |
- Returns:
- The maximum possible value since there is no alignment restriction (except indirectly through the size of the static_allocator_storage).
◆ max_node_size()
std::size_t wpi::memory::static_allocator::max_node_size |
( |
| ) |
const |
|
inlinenoexcept |
The documentation for this class was generated from the following file: