src/cx/mempool.h

changeset 1103
7c1e322b9165
parent 993
b642eca4b956
equal deleted inserted replaced
1102:db5e355e5349 1103:7c1e322b9165
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 /** 28 /**
29 * \file mempool.h 29 * @file mempool.h
30 * \brief Interface for memory pool implementations. 30 * @brief Interface for memory pool implementations.
31 * \author Mike Becker 31 * @author Mike Becker
32 * \author Olaf Wintermann 32 * @author Olaf Wintermann
33 * \copyright 2-Clause BSD License 33 * @copyright 2-Clause BSD License
34 */ 34 */
35 35
36 #ifndef UCX_MEMPOOL_H 36 #ifndef UCX_MEMPOOL_H
37 #define UCX_MEMPOOL_H 37 #define UCX_MEMPOOL_H
38 38
87 * 87 *
88 * This destructor MUST NOT free the memory. 88 * This destructor MUST NOT free the memory.
89 * 89 *
90 * @param capacity the initial capacity of the pool 90 * @param capacity the initial capacity of the pool
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(cxMempoolFree, 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 *
102 * @param capacity the initial capacity of the pool 102 * @param capacity (@c size_t) the initial capacity of the pool
103 * @return the created memory pool or \c NULL if allocation failed 103 * @return (@c CxMempool*) the created memory pool or @c NULL if allocation failed
104 */ 104 */
105 #define cxBasicMempoolCreate(capacity) cxMempoolCreate(capacity, NULL) 105 #define cxBasicMempoolCreate(capacity) cxMempoolCreate(capacity, NULL)
106 106
107 /** 107 /**
108 * Sets the destructor function for a specific allocated memory object. 108 * Sets the destructor function for a specific allocated memory object.
139 * If that allocation fails, this function will return non-zero. 139 * If that allocation fails, this function will return non-zero.
140 * 140 *
141 * @param pool the pool 141 * @param pool the pool
142 * @param memory the object to register (MUST NOT be already allocated in the pool) 142 * @param memory the object to register (MUST NOT be already allocated in the pool)
143 * @param destr the destructor function 143 * @param destr the destructor function
144 * @return zero on success, non-zero on failure 144 * @retval zero success
145 * @retval non-zero failure
145 */ 146 */
146 cx_attr_nonnull 147 cx_attr_nonnull
147 int cxMempoolRegister( 148 int cxMempoolRegister(
148 CxMempool *pool, 149 CxMempool *pool,
149 void *memory, 150 void *memory,

mercurial