Celartem::MemoryAllocator Class Reference

#include <cel_memory.h>

List of all members.

Public Member Functions

virtual CEL_RESTRICT_RETVAL void * allocate (size_t inBlockSize)=0
virtual void free (void *inMemoryBlockPtr)=0
virtual ~MemoryAllocator ()

Static Public Member Functions

static MemoryAllocatorgetDefault ()
static void setDefault (MemoryAllocator *inAllocator)


Detailed Description

MemoryAllocator class defines the interface for the memory allocator used in this library. You can define a new memory allocator by implementing this interface and if you want to use it as the default, call setDefault function.
Since MemoryAllocator class is potentially called from several threads, allocate and free should be thread-safe.

Definition at line 37 of file cel_memory.h.


Constructor & Destructor Documentation

virtual Celartem::MemoryAllocator::~MemoryAllocator (  )  [inline, virtual]

Destuctor is virtual since this class defines the interface.

Definition at line 89 of file cel_memory.h.


Member Function Documentation

virtual CEL_RESTRICT_RETVAL void* Celartem::MemoryAllocator::allocate ( size_t  inBlockSize  )  [pure virtual]

This method allocates a memory block of the specified block size. By default, the behavior is identical to std::malloc.

Parameters:
inBlockSize Specifies the block size in bytes.
Returns:
Pointer to the newly allocated memory block.
See also:
free

virtual void Celartem::MemoryAllocator::free ( void *  inMemoryBlockPtr  )  [pure virtual]

This method releases the specified memory block, which was allocated by allocate method. By default, the behavior is identical to std::free.

Parameters:
inMemoryBlockPtr Specifies the memory block to be released.
See also:
allocate

Referenced by Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::free().

static MemoryAllocator* Celartem::MemoryAllocator::getDefault (  )  [static]

This function returns the default memory allocator.

Returns:
Pointer to the default memory allocator.
See also:
setDefault

Referenced by Celartem::SimpleArray< Celartem::AutoPtr< Celartem::Image > >::init().

static void Celartem::MemoryAllocator::setDefault ( MemoryAllocator inAllocator  )  [static]

This function replaces the default memory allocator. Please note that you should call this function before calling any other function in this library. Replacing the default allocator after using some function of the library may break the consistency of the memory allocation and causes the serious runtime error.

Parameters:
inAllocator Pointer to the memory allocator.
See also:
getDefault


The documentation for this class was generated from the following file:
This document is automatically generated using doxygen 1.5.4 at Fri Jun 27 18:23:18 2008.