Concrete Python  git-339c971
Classes | Public Types | Public Member Functions | Static Public Member Functions
Allocator Class Reference

#include <concrete/allocation.hpp>

+ Inheritance diagram for Allocator:
+ Collaboration diagram for Allocator:

List of all members.

Classes

struct  Allocation
struct  FreeNode

Public Types

enum  { Alignment }
enum  { InitialAddress }

Public Member Functions

 Allocator (size_t size_limit) throw ()
 Allocator (void *data, size_t size, size_t size_limit) throw ()
 ~Allocator () throw ()
Allocation allocate (size_t size) throw ()
bool free (unsigned int address, void *data, size_t size) throw ()

Static Public Member Functions

static uint32_t AlignedSize (size_t size) throw ()

Detailed Description

Arena memory allocator implementation.


Member Enumeration Documentation

anonymous enum
Enumerator:
Alignment 

Alignment for allocation start addresses in bytes.

anonymous enum
Enumerator:
InitialAddress 

Guaranteed Arena offset of the first allocation.


Constructor & Destructor Documentation

Allocator ( size_t  size_limit) throw () [explicit]

Start with an empty arena.

Parameters:
size_limitdefines the maximum size of the arena
Allocator ( void *  data,
size_t  size,
size_t  size_limit 
) throw ()

Start with a populated arena. If the provided data is invalid, future free() calls may fail.

Parameters:
dataof the arena; will be stolen
sizeof the arena in bytes
size_limitdefines the maximum size of the arena
~Allocator ( ) throw ()

Deallocate the arena.


Member Function Documentation

static uint32_t AlignedSize ( size_t  size) throw () [static]
Returns:
size aligned according to Alignment
Allocator::Allocation allocate ( size_t  size) throw ()

Allocate a block of memory.

Parameters:
sizeof the memory block
bool free ( unsigned int  address,
void *  data,
size_t  size 
) throw ()

Free a block of memory.

Parameters:
addressof the memory block within the arena
datapointer to the memory block
sizeof the memory block
Returns:
false if the arena is corrupted