--- a/ucx/mempool.h Fri Sep 22 20:19:00 2017 +0200 +++ b/ucx/mempool.h Fri Sep 22 20:42:33 2017 +0200 @@ -70,39 +70,29 @@ /** * Creates a memory pool with the specified initial size. * - * As the created memory pool automatically grows in size by 16 elements, when + * As the created memory pool automatically grows in size by factor two when * trying to allocate memory on a full pool, it is recommended that you use - * a multiple of 16 for the initial size. + * a power of two for the initial size. * - * @param n initial pool size (should be a multiple of 16) + * @param n initial pool size (should be a power of two, e.g. 16) * @return a pointer to the new memory pool + * @see ucx_mempool_new_default() */ UcxMempool *ucx_mempool_new(size_t n); /** * Resizes a memory pool. * + * This function will fail if the new capacity is not sufficient for the + * present data. + * * @param pool the pool to resize * @param newcap the new capacity - * @return <code>EXIT_SUCCESS</code> on success or - * <code>EXIT_FAILURE</code> on failure + * @return zero on success or non-zero on failure */ int ucx_mempool_chcap(UcxMempool *pool, size_t newcap); /** - * Changes the pool size to the next smallest multiple of 16. - * - * You may use this macro, to reduce the pool size after freeing - * many pooled memory items. - * - * @param pool the pool to clamp - * @return <code>EXIT_SUCCESS</code> on success or - * <code>EXIT_FAILURE</code> on failure - */ -#define ucx_mempool_clamp(pool) ucx_mempool_chcap(pool, \ - (pool->ndata & ~0xF)+0x10) - -/** * Allocates pooled memory. * * @param pool the memory pool @@ -145,7 +135,7 @@ * is called. * * If you specify memory, that is not pooled by the specified memory pool, the - * behavior is undefined. + * program will terminate with a call to <code>abort()</code>. * * @param pool the memory pool * @param ptr a pointer to the memory that shall be freed