#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 MemoryAllocator * | getDefault () |
static void | setDefault (MemoryAllocator *inAllocator) |
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.
|
inlinevirtual |
Destuctor is virtual since this class defines the interface.
|
pure virtual |
This method allocates a memory block of the specified block size. By default, the behavior is identical to std::malloc
.
inBlockSize | Specifies the block size in bytes. |
|
pure virtual |
This method releases the specified memory block, which was allocated by allocate method. By default, the behavior is identical to std::free
.
inMemoryBlockPtr | Specifies the memory block to be released. |
Referenced by Celartem::SimpleArray< AutoPtr< Bookmark > >::free().
|
pure virtual |
This method obtains the actual memory block size in bytes.
inMemoryBlockPtr | Specifies the memory block to be released. |
Referenced by Celartem::SimpleArray< AutoPtr< Bookmark > >::getReservedSize().
|
static |
This function returns the default memory allocator.
Referenced by Celartem::SimpleArray< AutoPtr< Bookmark > >::getAllocator(), and Celartem::SimpleArray< AutoPtr< Bookmark > >::init().
|
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.
inAllocator | Pointer to the memory allocator. |