ClanLib
2.3.7
|
Memory allocator that allocates in blocks. More...
#include <block_allocator.h>
Public Member Functions | |
Construction | |
CL_BlockAllocator () | |
Block Allocator constructor. More... | |
Operations | |
void * | allocate (int size) |
Allocate memory (See note on this class for the allocation method) More... | |
void | free () |
Free the allocated memory. More... | |
template<typename Type > | |
Type * | new_obj () |
Allocate a class (And call it's constructor) More... | |
template<typename Type , typename P1 > | |
Type * | new_obj (P1 p1) |
Allocate a class (And call it's constructor) More... | |
template<typename Type , typename P1 , typename P2 > | |
Type * | new_obj (P1 p1, P2 p2) |
Allocate a class (And call it's constructor) More... | |
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) More... | |
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) More... | |
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) More... | |
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) More... | |
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) More... | |
template<typename Type > | |
void | delete_obj (Type *obj) |
Call the class destructor. More... | |
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.
CL_BlockAllocator::CL_BlockAllocator | ( | ) |
Block Allocator constructor.
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)
|
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
|
inline |
Allocate a class (And call it's constructor)
|
inline |
Allocate a class (And call it's constructor)
param: p1 = Parameter 1
|
inline |
Allocate a class (And call it's constructor)
param: p1 = Parameter 1 param: p2 = Parameter 2
|
inline |
Allocate a class (And call it's constructor)
param: p1 = Parameter 1 param: p2 = Parameter 2 param: p3 = Parameter 3
|
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
|
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
|
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
|
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