#include <b2SlabAllocator.h>
Public Member Functions | |
| b2SlabAllocator (const uint32 itemsPerSlab) | |
| ~b2SlabAllocator () | |
| Free all allocated slabs. | |
| void | SetItemsPerSlab (uint32 itemsPerSlab) |
| uint32 | GetItemsPerSlab () const |
| T * | Allocate () |
| Allocate a item from the slab. | |
| void | Free (T *object) |
| Free an item from the slab. | |
| bool | AllocateSlab () |
| void | FreeAllSlabs () |
| Free all slabs. | |
| void | FreeEmptySlabs () |
| const b2TypedFreeList< T > & | GetFreeList () const |
| Get the item allocator freelist. | |
Freelist based allocator for fixed sized items from slabs (memory preallocated from the heap). T should be a class which has a default constructor and implements the member function "b2IntrusiveList* GetListNode()". All objects in a slab are constructed when a slab is created and destructed when a slab is freed.
|
inline |
Initialize the allocator to allocate itemsPerSlab of type T for each slab that is allocated.
|
inline |
Allocate a slab, construct instances of T and add them to the free pool.
|
inline |
Free all empty slabs. This method is slow - O(M^N) - since this class doesn't track the association between each item and slab.
|
inline |
Set size of the next allocated slab using the number of items per slab. Setting this value to zero disables further slab allocation.