diff -r 6384016df2a3 -r 8693d7874773 test/mpool_tests.c --- a/test/mpool_tests.c Mon Jul 15 15:43:18 2013 +0200 +++ b/test/mpool_tests.c Mon Jul 15 16:59:52 2013 +0200 @@ -37,7 +37,7 @@ UCX_TEST_ASSERT(pool->ndata == 0, "uninitialized counter"); UCX_TEST_ASSERT(pool->data != NULL, "no memory addressed"); UCX_TEST_END - ucx_mempool_free(pool); + ucx_mempool_destroy(pool); } UCX_TEST_IMPLEMENT(test_ucx_mempool_malloc) { @@ -56,7 +56,7 @@ UCX_TEST_ASSERT(*test == 5, "wrong pointer"); UCX_TEST_END - ucx_mempool_free(pool); + ucx_mempool_destroy(pool); } UCX_TEST_IMPLEMENT(test_ucx_mempool_malloc_with_chcap) { @@ -76,7 +76,7 @@ UCX_TEST_ASSERT(*test == 5, "wrong pointer"); UCX_TEST_END - ucx_mempool_free(pool); + ucx_mempool_destroy(pool); } UCX_TEST_IMPLEMENT(test_ucx_mempool_calloc) { @@ -90,7 +90,37 @@ UCX_TEST_ASSERT(test[0] == 0 && test[1] == 0, "failed"); UCX_TEST_END - ucx_mempool_free(pool); + ucx_mempool_destroy(pool); +} + +UCX_TEST_IMPLEMENT(test_ucx_mempool_free) { + UcxMempool *pool = ucx_mempool_new(16); + void *mem1; + void *mem2; + + UCX_TEST_BEGIN + + mem1 = ucx_mempool_malloc(pool, 16); + ucx_mempool_free(pool, mem1); + + UCX_TEST_ASSERT(pool->ndata == 0, "mempool not empty"); + + ucx_mempool_malloc(pool, 16); + ucx_mempool_malloc(pool, 16); + mem1 = ucx_mempool_malloc(pool, 16); + ucx_mempool_malloc(pool, 16); + mem2 = ucx_mempool_malloc(pool, 16); + + ucx_mempool_free(pool, mem1); + + UCX_TEST_ASSERT(pool->ndata == 4, "wrong mempool size"); + + ucx_mempool_free(pool, mem2); + + UCX_TEST_ASSERT(pool->ndata == 3, "wrong mempool size"); + + UCX_TEST_END + ucx_mempool_destroy(pool); } void test_setdestr(void* elem) { @@ -118,7 +148,7 @@ UCX_TEST_ASSERT( test[0] == 5 && test[1] == (intptr_t) cb, "setdestr destroyed data") - ucx_mempool_free(pool); + ucx_mempool_destroy(pool); UCX_TEST_ASSERT(*cb == 42, "destructor not called"); @@ -146,7 +176,7 @@ UCX_TEST_ASSERT(*pooladdr == test_setdestr, "failed"); - ucx_mempool_free(pool); + ucx_mempool_destroy(pool); UCX_TEST_ASSERT(*cb == 42, "destructor not called"); UCX_TEST_END @@ -183,7 +213,7 @@ UCX_TEST_ASSERT( test[0] == 5 && test[1] == (intptr_t) cb, "realloc destroyed data") - ucx_mempool_free(pool); + ucx_mempool_destroy(pool); UCX_TEST_ASSERT(*cb == 42, "destructor not called");