diff -r eb5269000bc8 -r eeb50c534497 ucx/mempool.c --- a/ucx/mempool.c Sun Dec 08 11:20:41 2013 +0000 +++ b/ucx/mempool.c Fri Mar 21 13:20:53 2014 +0100 @@ -75,6 +75,20 @@ pool->ndata = 0; pool->size = n; + + UcxAllocator *allocator = (UcxAllocator*)malloc(sizeof(UcxAllocator)); + if(!allocator) { + free(pool->data); + free(pool); + return NULL; + } + allocator->malloc = (ucx_allocator_malloc)ucx_mempool_malloc; + allocator->calloc = (ucx_allocator_calloc)ucx_mempool_calloc; + allocator->realloc = (ucx_allocator_realloc)ucx_mempool_realloc; + allocator->free = (ucx_allocator_free)ucx_mempool_free; + allocator->pool = pool; + pool->allocator = allocator; + return pool; } @@ -173,6 +187,7 @@ } } free(pool->data); + free(pool->allocator); free(pool); } @@ -189,16 +204,3 @@ ucx_mempool_set_destr(rd, ucx_mempool_shared_destr); } -UcxAllocator* ucx_mempool_allocator(UcxMempool *pool) { - UcxAllocator *allocator = (UcxAllocator*)ucx_mempool_malloc( - pool, sizeof(UcxAllocator)); - if(!allocator) { - return NULL; - } - allocator->malloc = (ucx_allocator_malloc)ucx_mempool_malloc; - allocator->calloc = (ucx_allocator_calloc)ucx_mempool_calloc; - allocator->realloc = (ucx_allocator_realloc)ucx_mempool_realloc; - allocator->free = (ucx_allocator_free)ucx_mempool_free; - allocator->pool = pool; - return allocator; -}