![]() |
ucx
UAP Common Extensions
|
Interface for memory pool implementations. More...
Go to the source code of this file.
Data Structures | |
struct | cx_mempool_s |
The basic structure of a memory pool. More... | |
Macros | |
#define | cxMempoolCreateSimple(capacity) cxMempoolCreate(capacity, NULL) |
Creates a basic array-based memory pool. | |
Typedefs | |
typedef struct cx_mempool_s | CxMempool |
Common type for all memory pool implementations. | |
Functions | |
void | cxMempoolFree (CxMempool *pool) |
Deallocates a memory pool and frees the managed memory. | |
CxMempool * | cxMempoolCreate (size_t capacity, cx_destructor_func destr) |
Creates an array-based memory pool with a shared destructor function. | |
void | cxMempoolSetDestructor (void *memory, cx_destructor_func fnc) |
Sets the destructor function for a specific allocated memory object. | |
void | cxMempoolRemoveDestructor (void *memory) |
Removes the destructor function for a specific allocated memory object. | |
int | cxMempoolRegister (CxMempool *pool, void *memory, cx_destructor_func destr) |
Registers foreign memory with this pool. | |
Interface for memory pool implementations.
#define cxMempoolCreateSimple | ( | capacity | ) | cxMempoolCreate(capacity, NULL) |
Creates a basic array-based memory pool.
capacity | (size_t ) the initial capacity of the pool |
CxMempool*
) the created memory pool or NULL
if allocation failed CxMempool * cxMempoolCreate | ( | size_t | capacity, |
cx_destructor_func | destr ) |
Creates an array-based memory pool with a shared destructor function.
This destructor MUST NOT free the memory.
capacity | the initial capacity of the pool |
destr | optional destructor function to use for allocated memory |
NULL
if allocation failed void cxMempoolFree | ( | CxMempool * | pool | ) |
Deallocates a memory pool and frees the managed memory.
pool | the memory pool to free |
int cxMempoolRegister | ( | CxMempool * | pool, |
void * | memory, | ||
cx_destructor_func | destr ) |
Registers foreign memory with this pool.
The destructor, in contrast to memory allocated by the pool, MUST free the memory.
A small portion of memory will be allocated to register the information in the pool. If that allocation fails, this function will return non-zero.
pool | the pool |
memory | the object to register (MUST NOT be already allocated in the pool) |
destr | the destructor function |
zero | success |
non-zero | failure |
void cxMempoolRemoveDestructor | ( | void * | memory | ) |
Removes the destructor function for a specific allocated memory object.
If the memory is not managed by a UCX memory pool, the behavior is undefined. The destructor MUST NOT free the memory.
memory | the object allocated in the pool |
void cxMempoolSetDestructor | ( | void * | memory, |
cx_destructor_func | fnc ) |
Sets the destructor function for a specific allocated memory object.
If the memory is not managed by a UCX memory pool, the behavior is undefined. The destructor MUST NOT free the memory.
memory | the object allocated in the pool |
fnc | the destructor function |