74 * Common type for all memory pool implementations. |
74 * Common type for all memory pool implementations. |
75 */ |
75 */ |
76 typedef struct cx_mempool_s CxMempool; |
76 typedef struct cx_mempool_s CxMempool; |
77 |
77 |
78 /** |
78 /** |
79 * Destroys a memory pool and frees the managed memory. |
79 * Deallocates a memory pool and frees the managed memory. |
80 * |
80 * |
81 * @param pool the memory pool to destroy |
81 * @param pool the memory pool to free |
82 */ |
82 */ |
83 void cxMempoolDestroy(CxMempool *pool); |
83 void cxMempoolFree(CxMempool *pool); |
84 |
84 |
85 /** |
85 /** |
86 * Creates an array-based memory pool with a shared destructor function. |
86 * Creates an array-based memory pool with a shared destructor function. |
87 * |
87 * |
88 * This destructor MUST NOT free the memory. |
88 * This destructor MUST NOT free the memory. |
91 * @param destr optional destructor function to use for allocated memory |
91 * @param destr optional destructor function to use for allocated memory |
92 * @return the created memory pool or \c NULL if allocation failed |
92 * @return the created memory pool or \c NULL if allocation failed |
93 */ |
93 */ |
94 cx_attr_nodiscard |
94 cx_attr_nodiscard |
95 cx_attr_malloc |
95 cx_attr_malloc |
96 cx_attr_dealloc(cxMempoolDestroy, 1) |
96 cx_attr_dealloc(cxMempoolFree, 1) |
97 CxMempool *cxMempoolCreate(size_t capacity, cx_destructor_func destr); |
97 CxMempool *cxMempoolCreate(size_t capacity, cx_destructor_func destr); |
98 |
98 |
99 /** |
99 /** |
100 * Creates a basic array-based memory pool. |
100 * Creates a basic array-based memory pool. |
101 * |
101 * |