Public Member Functions | Static Public Member Functions | List of all members
Celartem::MemoryAllocator Class Referenceabstract

#include <cel_memory.h>

Public Member Functions

virtual CEL_RESTRICT_RETVAL void * allocate (size_t inBlockSize)=0
 
virtual void free (void *inMemoryBlockPtr)=0
 
virtual size_t getBlockSize (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.

Constructor & Destructor Documentation

virtual Celartem::MemoryAllocator::~MemoryAllocator ( )
inlinevirtual

Destuctor is virtual since this class defines the interface.

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
inBlockSizeSpecifies 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
inMemoryBlockPtrSpecifies the memory block to be released.
See Also
allocate

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

virtual size_t Celartem::MemoryAllocator::getBlockSize ( void *  inMemoryBlockPtr)
pure virtual

This method obtains the actual memory block size in bytes.

Parameters
inMemoryBlockPtrSpecifies the memory block to be released.
See Also
allocate

Referenced by Celartem::SimpleArray< AutoPtr< Bookmark > >::getReservedSize().

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< AutoPtr< Bookmark > >::getAllocator(), and Celartem::SimpleArray< AutoPtr< Bookmark > >::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
inAllocatorPointer to the memory allocator.
See Also
getDefault

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

Cuminas DjVu SDK 3.0.33103
This document is made with doxygen 1.8.5 at Sun Dec 15 2013 19:38:06.
Cuminas Logo