Block allocator.
More...
#include <BlockAllocator.hpp>
Block allocator.
This is a small object allocator used for allocating small objects that persist for more than one time step.
- Note
- This data structure is 136-bytes large (on at least one 64-bit platform).
- 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:=
{
16, 32, 64, 96, 128, 160, 192, 224, 256, 320, 384, 448, 512, 640,
}
Allocator block sizes array data.
Referenced by Allocate(), Free(), and GetMaxBlockSize().
The documentation for this class was generated from the following files:
- BlockAllocator.hpp
- BlockAllocator.cpp