clan::BlockAllocator Class Reference - ClanLib SDK
Description: clan::BlockAllocator Class Reference

Public Member Functions | List of all members
clan::BlockAllocator Class Reference
clanCore System

Memory allocator that allocates in blocks. More...

`#include <block_allocator.h>`

## Public Member Functions
| BlockAllocator ()
| Block Allocator constructor.
void * | allocate (int size)
| Allocate memory (See note on this class for the allocation method).
void | free ()
| Free the allocated memory.

## 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 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

## ◆ BlockAllocator()

clan::BlockAllocator::BlockAllocator | ( |  | ) |

Block Allocator constructor.

## Member Function Documentation

## ◆ allocate()

void * clan::BlockAllocator::allocate | ( | int | size | ) |

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

param: size = Size to allocate (in bytes)

Returns
  The memory

## ◆ free()

void clan::BlockAllocator::free | ( |  | ) |

Free the allocated memory.

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

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

- block_allocator.h