Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Moteur3D::MemoryAllocator Class Reference

The MemoryAllocator class allows you to allocate a whole memory block at once and distribute it when needed. Its main purpose is to remove the malloc overhead each time you want to allocate and deallocate memory. More...

#include <MemoryAllocator.h>

List of all members.

Public Member Functions

 MemoryAllocator ()
 Constructor.
 ~MemoryAllocator ()
 Destructor.
int Init (size_t nbytes)
 Initialises the allocator. Call it after instantiation (of course !) but before using any new operator.

Protected Member Functions

 MemoryAllocator (const MemoryAllocator &ma)
 Copy constructor. Should NOT be called.
MemoryAllocatoroperator= (const MemoryAllocator &ma)
 Affectation operator. Should NOT be called.
void * Allocate (size_t nbytes)
 Allocates memory, used by operator new.
int Release (void *pFrame)
 Releases memory, used by operator delete.

Protected Attributes

char * m_MemoryBlock
 Memory block allocated by the class.
char * m_BasePointer
 Memoy block's aligned base pointer.
char * m_TopPointer
 Memoy block's aligned top pointer.

Friends

void * operator new (size_t bytes, Moteur3D::MemoryAllocator &ma)
void * operator new (size_t bytes, Moteur3D::MemoryAllocator *ma)
void operator delete (void *p, Moteur3D::MemoryAllocator &ma)
void operator delete (void *p, Moteur3D::MemoryAllocator *ma)


Detailed Description

The MemoryAllocator class allows you to allocate a whole memory block at once and distribute it when needed. Its main purpose is to remove the malloc overhead each time you want to allocate and deallocate memory.

In order to use this allocator, you just have to use the following syntax : Foo f = new (ma) Foo(); where ma is an instance of MemoryAllocator.
Note that this class is still under developpment, for now you can only allocate and deallocate memory as if it was a stack, and the alignment is hard-coded as 16 bytes.


Constructor & Destructor Documentation

Moteur3D::MemoryAllocator::MemoryAllocator  ) 
 

Constructor.

Moteur3D::MemoryAllocator::~MemoryAllocator  ) 
 

Destructor.

Moteur3D::MemoryAllocator::MemoryAllocator const MemoryAllocator ma  )  [protected]
 

Copy constructor. Should NOT be called.


Member Function Documentation

void* Moteur3D::MemoryAllocator::Allocate size_t  nbytes  )  [protected]
 

Allocates memory, used by operator new.

int Moteur3D::MemoryAllocator::Init size_t  nbytes  ) 
 

Initialises the allocator. Call it after instantiation (of course !) but before using any new operator.

MemoryAllocator& Moteur3D::MemoryAllocator::operator= const MemoryAllocator ma  )  [protected]
 

Affectation operator. Should NOT be called.

int Moteur3D::MemoryAllocator::Release void *  pFrame  )  [protected]
 

Releases memory, used by operator delete.


Friends And Related Function Documentation

void operator delete void *  p,
Moteur3D::MemoryAllocator ma
[friend]
 

void operator delete void *  p,
Moteur3D::MemoryAllocator ma
[friend]
 

void* operator new size_t  bytes,
Moteur3D::MemoryAllocator ma
[friend]
 

void* operator new size_t  bytes,
Moteur3D::MemoryAllocator ma
[friend]
 


Member Data Documentation

char* Moteur3D::MemoryAllocator::m_BasePointer [protected]
 

Memoy block's aligned base pointer.

char* Moteur3D::MemoryAllocator::m_MemoryBlock [protected]
 

Memory block allocated by the class.

char* Moteur3D::MemoryAllocator::m_TopPointer [protected]
 

Memoy block's aligned top pointer.


The documentation for this class was generated from the following file:
Generated on Sat Oct 15 15:05:52 2005 for Moteur3D by  doxygen 1.4.4