|
Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
|
Memory allocation and deallocation Interface class.
This abstract interface class is used by some of the Barracuda classes when allocating memory. The reason for using an interface class and not directly calling the global functions baMalloc(), baRealloc() and baFree() is to provide a finer control of allocated memory. For example, an implementation of the AllocatorIntf can work with blocks of memory allocated from static memory. Implementing realloc is optional and can be set to NULL if not implemented.
#include <AllocatorIntf.h>

Public Member Functions | |
| AllocatorIntf () | |
| Leave callbacks uninitialized; initialize them before use. More... | |
| AllocatorIntf (AllocatorIntf_Malloc malloc, AllocatorIntf_Realloc realloc, AllocatorIntf_Free free) | |
| Create an instance of a memory allocation class. More... | |
| void * | malloc (size_t *size) |
| Allocate uninitialized storage. More... | |
| void * | malloc (size_t size) |
| Allocate without returning the adjusted allocation size. More... | |
| void * | realloc (void *p, size_t *size) |
| Resize an allocation. More... | |
| void * | realloc (void *p, size_t size) |
| Resize without returning the adjusted allocation size. More... | |
| void | free (void *p) |
| Release an allocation. More... | |
Static Public Member Functions | |
| static AllocatorIntf * | getDefault (void) |
| Obtain the shared allocator backed by baMalloc, baRealloc and baFree. More... | |
| AllocatorIntf::AllocatorIntf | ( | ) |
Leave callbacks uninitialized; initialize them before use.
| AllocatorIntf::AllocatorIntf | ( | AllocatorIntf_Malloc | malloc, |
| AllocatorIntf_Realloc | realloc, | ||
| AllocatorIntf_Free | free | ||
| ) |
Create an instance of a memory allocation class.
This is an abstract base class and should, therefore, be sub-classed.
| malloc | Required allocation callback, retained without copying. |
| realloc | Pointer to memory reallocation method. This method is optional and the argument can be set to NULL if not implemented. |
| free | Required deallocation callback, retained without copying. |
| void AllocatorIntf::free | ( | void * | p | ) |
Release an allocation.
| [in] | p | Live block from this allocator. NULL is allowed only if the installed callback supports it; see AllocatorIntf_Free. |
|
static |
Obtain the shared allocator backed by baMalloc, baRealloc and baFree.
| void * AllocatorIntf::malloc | ( | size_t * | size | ) |
Allocate uninitialized storage.
| [in,out] | size | Requested byte count, possibly increased on success. |
| void * AllocatorIntf::malloc | ( | size_t | size | ) |
Allocate without returning the adjusted allocation size.
| [in] | size | Requested byte count. |
| void * AllocatorIntf::realloc | ( | void * | p, |
| size_t * | size | ||
| ) |
Resize an allocation.
| [in] | p | Block allocated by this allocator, or NULL. |
| [in,out] | size | Requested byte count, possibly increased on success. |
| void * AllocatorIntf::realloc | ( | void * | p, |
| size_t | size | ||
| ) |
Resize without returning the adjusted allocation size.
| [in] | p | Block allocated by this allocator, or NULL. |
| [in] | size | Requested byte count. |