"L. Spiro Engine"
|
Stack allocators allocate from the top of a stack and from no where else. More...
#include <LSAStackAllocator.h>
Classes | |
struct | LSA_STACK |
Public Member Functions | |
LSVOID *LSE_CALL | Alloc (LSA_SIZE _sSize, LSUINT32 _ui32Align=16UL) |
LSVOID LSE_CALL | Reset () |
Protected Types | |
typedef struct lsa::CStackAllocator::LSA_STACK * | LPLSA_STACK |
typedef struct lsa::CStackAllocator::LSA_STACK | LPCLSA_STACK |
Protected Member Functions | |
LSBOOL LSE_CALL | AddStack (LSA_SIZE _sSize) |
Protected Attributes | |
LSA_STACK * | m_psHead |
LSA_STACK * | m_psSearchStart |
Stack allocators allocate from the top of a stack and from no where else.
Class CStackAllocator Description: Stack allocators allocate from the top of a stack and from no where else. They are designed to provide instant allocation but do not offer any way to free individual addresses. This facilitates systems that never allocate more than they need and free all of their allocations at the end of their lives. Allocation time is reduced dramatically and release time is entirely eliminated, and there is no book-keeping for each allocation allowing for an extreme gain in efficiency. With proper organization, this type of allocator can be the most useful of all allocators.
typedef struct lsa::CStackAllocator::LSA_STACK * lsa::CStackAllocator::LPLSA_STACK [protected] |
Keeps track of a single stack of addresses.
LSBOOL LSE_CALL lsa::CStackAllocator::AddStack | ( | LSA_SIZE | _sSize | ) | [protected] |
Adds a stack to the linked list of stacks with the given size.
_sSize | Size of the stack to add. |
LSVOID* LSE_CALL lsa::CStackAllocator::Alloc | ( | LSA_SIZE | _sSize, |
LSUINT32 | _ui32Align = 16UL |
||
) |
Allocate RAM. If there is not enough and the heap can grow, it tries to grow the heap.
_sSize | Amount of RAM to allocate. |
_ui32Align | Alignment of the RAM to allocate. Can be any power of 2. |
LSVOID LSE_CALL lsa::CStackAllocator::Reset | ( | ) |
Resets the stack allocator completely, releasing all resources back to the operating system.
LSA_STACK* lsa::CStackAllocator::m_psHead [protected] |
The first stack in the linked list of stacks.
LSA_STACK* lsa::CStackAllocator::m_psSearchStart [protected] |
The first stack in the linked list with any remaining bytes that can be allocated.