ucx/mempool.h

changeset 141
c466e2a6cbd0
parent 135
a0aa1c15f46b
child 146
aa376dba1ba8
equal deleted inserted replaced
140:15f871f50bfd 141:c466e2a6cbd0
90 * <code>EXIT_FAILURE</code> on failure 90 * <code>EXIT_FAILURE</code> on failure
91 */ 91 */
92 int ucx_mempool_chcap(UcxMempool *pool, size_t newcap); 92 int ucx_mempool_chcap(UcxMempool *pool, size_t newcap);
93 93
94 /** 94 /**
95 * Changes the pool size to the next smallest multiple of 16.
96 *
97 * You may use this macro, to reduce the pool size after freeing
98 * many pooled memory items.
99 *
100 * @param pool the pool to clamp
101 * @return <code>EXIT_SUCCESS</code> on success or
102 * <code>EXIT_FAILURE</code> on failure
103 */
104 #define ucx_mempool_clamp(pool) ucx_mempool_chcap(pool, \
105 (pool->ndata & ~0xF)+0x10)
106
107 /**
95 * Allocates pooled memory. 108 * Allocates pooled memory.
96 * 109 *
97 * @param pool the memory pool 110 * @param pool the memory pool
98 * @param n amount of memory to allocate 111 * @param n amount of memory to allocate
99 * @return a pointer to the allocated memory 112 * @return a pointer to the allocated memory
113 */ 126 */
114 void *ucx_mempool_calloc(UcxMempool *pool, size_t nelem, size_t elsize); 127 void *ucx_mempool_calloc(UcxMempool *pool, size_t nelem, size_t elsize);
115 /** 128 /**
116 * Reallocates pooled memory. 129 * Reallocates pooled memory.
117 * 130 *
131 * If the memory to be reallocated is not contained by the specified pool, this
132 * function will possibly fail. In case the memory had to be moved to another
133 * location, this function will print out a message to <code>stderr</code>
134 * and exit the program with error code <code>EXIT_FAILURE</code>.
135 *
118 * @param pool the memory pool 136 * @param pool the memory pool
119 * @param ptr a pointer to the memory that shall be reallocated 137 * @param ptr a pointer to the memory that shall be reallocated
120 * @param n the new size of the memory 138 * @param n the new size of the memory
121 * @return a pointer to the the location of the memory 139 * @return a pointer to the the location of the memory
122 * @see ucx_allocator_realloc() 140 * @see ucx_allocator_realloc()

mercurial