#include <block_allocator.h>
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. | |
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.
|
|
Block Allocator constructor.
|
|
|
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)
|
|
||||||||||
|
Call the class destructor. This template does not call free() param: obj = the object which to call the destructor |
|
|
Free the allocated memory. If required, use delete_obj() to call the destructor before using this function |
|
||||||||||||||||||||||||||||||||||||
|
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
|
|
||||||||||||||||||||||||||||||||
|
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
|
|
||||||||||||||||||||||||||||
|
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
|
|
||||||||||||||||||||||||
|
Allocate a class (And call it's constructor). param: p1 = Parameter 1 param: p2 = Parameter 2 param: p3 = Parameter 3 param: p4 = Parameter 4
|
|
||||||||||||||||||||
|
Allocate a class (And call it's constructor). param: p1 = Parameter 1 param: p2 = Parameter 2 param: p3 = Parameter 3
|
|
||||||||||||||||
|
Allocate a class (And call it's constructor). param: p1 = Parameter 1 param: p2 = Parameter 2
|
|
||||||||||
|
Allocate a class (And call it's constructor). param: p1 = Parameter 1
|
|
|||||||||
|
Allocate a class (And call it's constructor).
|
1.4.6