"L. Spiro Engine"
Classes | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes

lsa::CStackAllocator Class Reference

Stack allocators allocate from the top of a stack and from no where else. More...

#include <LSAStackAllocator.h>

List of all members.

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_STACKm_psHead
LSA_STACKm_psSearchStart

Detailed Description

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.


Member Typedef Documentation

Keeps track of a single stack of addresses.


Member Function Documentation

LSBOOL LSE_CALL lsa::CStackAllocator::AddStack ( LSA_SIZE  _sSize) [protected]

Adds a stack to the linked list of stacks with the given size.

Parameters:
_sSizeSize of the stack to add.
Returns:
Returns true if there was enough memory to add a stack of the given size.
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.

Parameters:
_sSizeAmount of RAM to allocate.
_ui32AlignAlignment of the RAM to allocate. Can be any power of 2.
Returns:
Returns the allocated RAM or NULL if there is not enough RAM available to make the allocation.
LSVOID LSE_CALL lsa::CStackAllocator::Reset ( )

Resets the stack allocator completely, releasing all resources back to the operating system.


Member Data Documentation

The first stack in the linked list of stacks.

The first stack in the linked list with any remaining bytes that can be allocated.


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator