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... | |
Typedefs | |
typedef struct cx_mempool_s | CxMempool |
Common type for all memory pool implementations. | |
Functions | |
CxMempool * | cxMempoolCreate (size_t capacity, cx_destructor_func destr) |
Creates an array-based memory pool with a shared destructor function. | |
static CxMempool * | cxBasicMempoolCreate (size_t capacity) |
Creates a basic array-based memory pool. | |
void | cxMempoolDestroy (CxMempool *pool) |
Destroys a memory pool and frees the managed memory. | |
void | cxMempoolSetDestructor (void *memory, cx_destructor_func fnc) |
Sets 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.
|
inlinestatic |
Creates a basic array-based memory pool.
capacity | the initial capacity of the pool |
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 | the destructor function to use for allocated memory |
NULL
if allocation failed void cxMempoolDestroy | ( | CxMempool * | pool | ) |
Destroys a memory pool and frees the managed memory.
pool | the memory pool to destroy |
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 allocated in the pool |
destr | the destructor function |
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 |