CL_BlockAllocator Class Reference
[clanCore System]

Memory allocator that allocates in blocks. More...

#include <block_allocator.h>

List of all members.

Public Member Functions

Construction

 CL_BlockAllocator ()
 Block Allocator constructor.
Operations

void * allocate (int size)
 Allocate memory (See note on this class for the allocation method).
void free ()
 Free the allocated memory.
template<typename Type >
Type * new_obj ()
 Allocate a class (And call it's constructor).
template<typename Type , typename P1 >
Type * new_obj (P1 p1)
 Allocate a class (And call it's constructor).
template<typename Type , typename P1 , typename P2 >
Type * new_obj (P1 p1, P2 p2)
 Allocate a class (And call it's constructor).
template<typename Type , typename P1 , typename P2 , typename P3 >
Type * new_obj (P1 p1, P2 p2, P3 p3)
 Allocate a class (And call it's constructor).
template<typename Type , typename P1 , typename P2 , typename P3 , typename P4 >
Type * new_obj (P1 p1, P2 p2, P3 p3, P4 p4)
 Allocate a class (And call it's constructor).
template<typename Type , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 >
Type * new_obj (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
 Allocate a class (And call it's constructor).
template<typename Type , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6 >
Type * new_obj (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6)
 Allocate a class (And call it's constructor).
template<typename Type , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6 , typename P7 >
Type * new_obj (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7)
 Allocate a class (And call it's constructor).
template<typename Type >
void delete_obj (Type *obj)
 Call the class destructor.

Detailed Description

Memory allocator that allocates in blocks.

This allocator will never free any memory until free() is called or the allocator object is destroyed. If any objects have been new'ed using CL_BlockAllocated they have to be delete'ed before free() is called, otherwise the destructors of the objects will not get called. Same rules apply to the new_obj and delete_obj template functions.

The allocator allocates memory from the heap in blocks. Each time the allocated block is exhausted, the allocator will double the block size and allocate more memory.


Constructor & Destructor Documentation

CL_BlockAllocator::CL_BlockAllocator (  ) 

Block Allocator constructor.


Member Function Documentation

void* CL_BlockAllocator::allocate ( int  size  ) 

Allocate memory (See note on this class for the allocation method).

Also see: new_obj() which allocates and calls the constructor param: size = Size to allocate (in bytes)

Returns:
The memory
template<typename Type >
void CL_BlockAllocator::delete_obj ( Type *  obj  )  [inline]

Call the class destructor.

This template does not call free() param: obj = the object which to call the destructor

References CL_System::call_destructor().

void CL_BlockAllocator::free (  ) 

Free the allocated memory.

If required, use delete_obj() to call the destructor before using this function

template<typename Type , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6 >
Type* CL_BlockAllocator::new_obj ( P1  p1,
P2  p2,
P3  p3,
P4  p4,
P5  p5,
P6  p6 
) [inline]

Allocate a class (And call it's constructor).

param: p1 = Parameter 1 param: p2 = Parameter 2 param: p3 = Parameter 3 param: p4 = Parameter 4 param: p5 = Parameter 5 param: p6 = Parameter 6

Returns:
The class
template<typename Type , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 >
Type* CL_BlockAllocator::new_obj ( P1  p1,
P2  p2,
P3  p3,
P4  p4,
P5  p5 
) [inline]

Allocate a class (And call it's constructor).

param: p1 = Parameter 1 param: p2 = Parameter 2 param: p3 = Parameter 3 param: p4 = Parameter 4 param: p5 = Parameter 5

Returns:
The class
template<typename Type , typename P1 , typename P2 , typename P3 , typename P4 >
Type* CL_BlockAllocator::new_obj ( P1  p1,
P2  p2,
P3  p3,
P4  p4 
) [inline]

Allocate a class (And call it's constructor).

param: p1 = Parameter 1 param: p2 = Parameter 2 param: p3 = Parameter 3 param: p4 = Parameter 4

Returns:
The class
template<typename Type , typename P1 , typename P2 , typename P3 >
Type* CL_BlockAllocator::new_obj ( P1  p1,
P2  p2,
P3  p3 
) [inline]

Allocate a class (And call it's constructor).

param: p1 = Parameter 1 param: p2 = Parameter 2 param: p3 = Parameter 3

Returns:
The class
template<typename Type , typename P1 , typename P2 >
Type* CL_BlockAllocator::new_obj ( P1  p1,
P2  p2 
) [inline]

Allocate a class (And call it's constructor).

param: p1 = Parameter 1 param: p2 = Parameter 2

Returns:
The class
template<typename Type , typename P1 >
Type* CL_BlockAllocator::new_obj ( P1  p1  )  [inline]

Allocate a class (And call it's constructor).

param: p1 = Parameter 1

Returns:
The class
template<typename Type >
Type* CL_BlockAllocator::new_obj (  )  [inline]

Allocate a class (And call it's constructor).

Returns:
The class
template<typename Type , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6 , typename P7 >
Type* CL_BlockAllocator::new_obj ( P1  p1,
P2  p2,
P3  p3,
P4  p4,
P5  p5,
P6  p6,
P7  p7 
) [inline]

Allocate a class (And call it's constructor).

param: p1 = Parameter 1 param: p2 = Parameter 2 param: p3 = Parameter 3 param: p4 = Parameter 4 param: p5 = Parameter 5 param: p6 = Parameter 6 param: p7 = Parameter 7

Returns:
The class

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