#include <playrho/BlockAllocator.hpp>
Block allocator.
This is a small object allocator used for allocating small objects that persist for more than one time step.
- See also
- http://www.codeproject.com/useritems/Small_Block_Allocator.asp
◆ Allocate()
| void * playrho::BlockAllocator::Allocate |
( |
size_type |
n | ) |
|
Allocates memory.
Allocates uninitialized storage. Uses Alloc if the size is larger than GetMaxBlockSize(). Otherwise looks for an appropriately sized block from the free list. Failing that, Alloc is used to grow the free list from which memory is returned.
- Returns
- Non-null pointer if asked to make non-zero sized allocation,
nullptr otherwise.
- Exceptions
-
| std::bad_alloc | If unable to allocate non-zero size of memory. |
- See also
- Alloc.
Referenced by AllocateArray().
◆ AllocateArray()
template<typename T >
| T* playrho::BlockAllocator::AllocateArray |
( |
size_type |
n | ) |
|
|
inline |
Allocates an array.
- Exceptions
-
| std::bad_alloc | If unable to allocate non-zero elements of non-zero size. |
◆ Clear()
| void playrho::BlockAllocator::Clear |
( |
| ) |
|
Clears this allocator.
- Note
- This resets the chunk-count back to zero.
◆ Free()
| void playrho::BlockAllocator::Free |
( |
void * |
p, |
|
|
size_type |
n |
|
) |
| |
◆ AllocatorBlockSizes
| constexpr std::size_t playrho::BlockAllocator::AllocatorBlockSizes[] |
|
staticconstexpr |
Initial value:=
{
16u, 32u, 64u, 96u, 128u, 160u, 192u, 224u, 256u, 320u, 384u, 448u, 512u, 640u,
}
Allocator block sizes array data.
Referenced by Allocate(), Free(), and GetMaxBlockSize().
The documentation for this class was generated from the following files: