Menu

object::OneBlockAllocator< tag, mem_size > Class Template Reference

Pseudo-allocator supporting only one allocation. More...

#include <Allocator.h>

Data Structures

struct  Buffer

Public Types

typedef Buffer::SizeT SizeT
 Type used for allocation sizes.

Static Public Member Functions

static uint8_t * alloc (SizeT bytes)
 Allocate raw memory (no constructor call).
static void free (uint8_t *p)
 Free memory previously allocated by alloc().
template<typename T >
static T * alloc_array (SizeT num)
 Allocate array (no constructor call).
template<typename T >
static void free_array (T *p)
 Free array previously allocated by alloc_array().
template<typename T >
static void destroy (T *p)
 Destruct and free object previously allocated by allocator new.

Static Protected Member Functions

static Buffer & instance ()
 Singleton instance of Buffer.

Detailed Description

template<class tag, uint64_t mem_size>
class object::OneBlockAllocator< tag, mem_size >

Pseudo-allocator supporting only one allocation.

Template Parameters:
tag Type not used for internal purposes but to allow multiple OneBlockAllocators. Allocators with the same tag share one buffer (implemented as singleton).
mem_size Maximum allocateble size
See also:
object/Allocator.h

Member Typedef Documentation

template<class tag , uint64_t mem_size>
typedef Buffer::SizeT object::OneBlockAllocator< tag, mem_size >::SizeT

Type used for allocation sizes.


Member Function Documentation

template<class tag , uint64_t mem_size>
static uint8_t* object::OneBlockAllocator< tag, mem_size >::alloc ( SizeT  bytes  )  [inline, static]

Allocate raw memory (no constructor call).

Parameters:
bytes Number of bytes to allocate
Returns:
Pointer to uninitialized allocated memory or NULL on error.

References object::OneBlockAllocator< tag, mem_size >::instance().

Referenced by object::OneBlockAllocator< tag, mem_size >::alloc_array().

template<class tag , uint64_t mem_size>
template<typename T >
static T* object::OneBlockAllocator< tag, mem_size >::alloc_array ( SizeT  num  )  [inline, static]

Allocate array (no constructor call).

Template Parameters:
T Array element type
Parameters:
num Number of T items to allocate
Returns:
Pointer to uninitialized allocated memory or NULL on error.

References object::OneBlockAllocator< tag, mem_size >::alloc().

template<class tag , uint64_t mem_size>
template<typename T >
static void object::OneBlockAllocator< tag, mem_size >::destroy ( T *  p  )  [inline, static]

Destruct and free object previously allocated by allocator new.

Parameters:
p Pointer to object to free

References object::OneBlockAllocator< tag, mem_size >::free().

template<class tag , uint64_t mem_size>
static void object::OneBlockAllocator< tag, mem_size >::free ( uint8_t *  p  )  [inline, static]

Free memory previously allocated by alloc().

Parameters:
p Pointer to memory to free

References object::OneBlockAllocator< tag, mem_size >::instance().

Referenced by object::OneBlockAllocator< tag, mem_size >::destroy(), and object::OneBlockAllocator< tag, mem_size >::free_array().

template<class tag , uint64_t mem_size>
template<typename T >
static void object::OneBlockAllocator< tag, mem_size >::free_array ( T *  p  )  [inline, static]

Free array previously allocated by alloc_array().

Parameters:
p Pointer to memory to free
Note:
Does not call destuctors!

References object::OneBlockAllocator< tag, mem_size >::free().

template<class tag , uint64_t mem_size>
static Buffer& object::OneBlockAllocator< tag, mem_size >::instance (  )  [inline, static, protected]

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