Back to index

supertuxkart  0.5+dfsg1
Public Member Functions | Private Member Functions | Private Attributes
btStackAlloc Class Reference

StackAlloc provides some fast stack-based memory allocator (LIFO last-in first-out) More...

#include <btStackAlloc.h>

Collaboration diagram for btStackAlloc:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 btStackAlloc (unsigned int size)
 ~btStackAlloc ()
void create (unsigned int size)
void destroy ()
int getAvailableMemory () const
unsigned char * allocate (unsigned int size)
SIMD_FORCE_INLINE btBlockbeginBlock ()
SIMD_FORCE_INLINE void endBlock (btBlock *block)

Private Member Functions

void ctor ()

Private Attributes

unsigned char * data
unsigned int totalsize
unsigned int usedsize
btBlockcurrent
bool ischild

Detailed Description

StackAlloc provides some fast stack-based memory allocator (LIFO last-in first-out)

Definition at line 33 of file btStackAlloc.h.


Constructor & Destructor Documentation

btStackAlloc::btStackAlloc ( unsigned int  size) [inline]

Definition at line 37 of file btStackAlloc.h.

{ ctor();create(size); }

Here is the call graph for this function:

Definition at line 38 of file btStackAlloc.h.

{ destroy(); }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Function Documentation

unsigned char* btStackAlloc::allocate ( unsigned int  size) [inline]

Definition at line 67 of file btStackAlloc.h.

       {
              const unsigned int   nus(usedsize+size);
              if(nus<totalsize)
              {
                     usedsize=nus;
                     return(data+(usedsize-size));
              }
              btAssert(0);
              //&& (L"Not enough memory"));
              
              return(0);
       }

Here is the caller graph for this function:

Definition at line 80 of file btStackAlloc.h.

       {
              btBlock*      pb = (btBlock*)allocate(sizeof(btBlock));
              pb->previous  =      current;
              pb->address          =      data+usedsize;
              current                     =      pb;
              return(pb);
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void btStackAlloc::create ( unsigned int  size) [inline]

Definition at line 40 of file btStackAlloc.h.

       {
              destroy();
              data          =  (unsigned char*) btAlignedAlloc(size,16);
              totalsize     =      size;
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void btStackAlloc::ctor ( ) [inline, private]

Definition at line 100 of file btStackAlloc.h.

       {
              data          =      0;
              totalsize     =      0;
              usedsize      =      0;
              current              =      0;
              ischild              =      false;
       }

Here is the caller graph for this function:

void btStackAlloc::destroy ( ) [inline]

Definition at line 46 of file btStackAlloc.h.

       {
              btAssert(usedsize==0);
              //Raise(L"StackAlloc is still in use");

              if(usedsize==0)
              {
                     if(!ischild && data)        
                            btAlignedFree(data);

                     data                        =      0;
                     usedsize                    =      0;
              }
              
       }

Here is the caller graph for this function:

SIMD_FORCE_INLINE void btStackAlloc::endBlock ( btBlock block) [inline]

Definition at line 88 of file btStackAlloc.h.

       {
              btAssert(block==current);
              //Raise(L"Unmatched blocks");
              if(block==current)
              {
                     current              =      block->previous;
                     usedsize      =      (unsigned int)((block->address-data)-sizeof(btBlock));
              }
       }

Here is the caller graph for this function:

int btStackAlloc::getAvailableMemory ( ) const [inline]

Definition at line 62 of file btStackAlloc.h.

       {
              return totalsize - usedsize;
       }

Member Data Documentation

Definition at line 111 of file btStackAlloc.h.

unsigned char* btStackAlloc::data [private]

Definition at line 108 of file btStackAlloc.h.

bool btStackAlloc::ischild [private]

Definition at line 112 of file btStackAlloc.h.

unsigned int btStackAlloc::totalsize [private]

Definition at line 109 of file btStackAlloc.h.

unsigned int btStackAlloc::usedsize [private]

Definition at line 110 of file btStackAlloc.h.


The documentation for this class was generated from the following file: