1.1 --- a/ucx/mempool.h Fri Oct 05 10:25:33 2012 +0200 1.2 +++ b/ucx/mempool.h Fri Oct 05 11:52:53 2012 +0200 1.3 @@ -19,6 +19,26 @@ 1.4 size_t size; 1.5 } UcxMempool; 1.6 1.7 +typedef void*(*ucx_allocator_malloc)(UcxMempool *pool, size_t n); 1.8 +typedef void*(*ucx_allocator_calloc)(UcxMempool *pool, size_t n, size_t size); 1.9 +typedef void*(*ucx_allocator_realloc)(UcxMempool *pool, void *data, size_t n); 1.10 + 1.11 +typedef struct { 1.12 + UcxMempool *pool; 1.13 + ucx_allocator_malloc malloc; 1.14 + ucx_allocator_calloc calloc; 1.15 + ucx_allocator_realloc realloc; 1.16 +} UcxAllocator; 1.17 + 1.18 +#define UCX_ALLOCATOR_DEFAULT {NULL, \ 1.19 + ucx_default_malloc, ucx_default_calloc, ucx_default_realloc} 1.20 +#define UCX_ALLOCATOR_MEMPOOL(pool) {pool, \ 1.21 + ucx_mempool_malloc, ucx_mempool_calloc, ucx_mempool_realloc} 1.22 + 1.23 +void *ucx_default_malloc(UcxMempool *ignore, size_t n); 1.24 +void *ucx_default_calloc(UcxMempool *ignore, size_t n, size_t size); 1.25 +void *ucx_default_realloc(UcxMempool *ignore, void *data, size_t n); 1.26 + 1.27 #define ucx_mempool_new_default() ucx_mempool_new(16) 1.28 UcxMempool *ucx_mempool_new(size_t n); 1.29 int ucx_mempool_chcap(UcxMempool *pool, size_t newcap);