79 cxMempoolDestroy(pool); |
79 cxMempoolDestroy(pool); |
80 } |
80 } |
81 |
81 |
82 static unsigned test_mempool_destructor_called; |
82 static unsigned test_mempool_destructor_called; |
83 |
83 |
84 static void test_mempool_destructor(__attribute__((__unused__)) void *mem) { |
84 static void test_mempool_destructor(cx_attr_unused void *mem) { |
85 test_mempool_destructor_called++; |
85 test_mempool_destructor_called++; |
86 } |
86 } |
87 |
87 |
88 CX_TEST(test_mempool_realloc) { |
88 CX_TEST(test_mempool_realloc) { |
89 CxMempool *pool = cxMempoolCreate(4, test_mempool_destructor); |
89 CxMempool *pool = cxMempoolCreate(4, test_mempool_destructor); |
117 CX_TEST_DO { |
117 CX_TEST_DO { |
118 mem1 = cxMalloc(pool->allocator, 16); |
118 mem1 = cxMalloc(pool->allocator, 16); |
119 cxFree(pool->allocator, mem1); |
119 cxFree(pool->allocator, mem1); |
120 CX_TEST_ASSERT(pool->size == 0); |
120 CX_TEST_ASSERT(pool->size == 0); |
121 |
121 |
122 cxMalloc(pool->allocator, 16); |
|
123 cxMalloc(pool->allocator, 16); |
|
124 mem1 = cxMalloc(pool->allocator, 16); |
122 mem1 = cxMalloc(pool->allocator, 16); |
125 cxMalloc(pool->allocator, 16); |
123 mem1 = cxMalloc(pool->allocator, 16); |
|
124 mem1 = cxMalloc(pool->allocator, 16); |
|
125 mem2 = cxMalloc(pool->allocator, 16); |
126 mem2 = cxMalloc(pool->allocator, 16); |
126 mem2 = cxMalloc(pool->allocator, 16); |
127 |
127 |
128 CX_TEST_ASSERT(pool->size == 5); |
128 CX_TEST_ASSERT(pool->size == 5); |
129 cxFree(pool->allocator, mem1); |
129 cxFree(pool->allocator, mem1); |
130 CX_TEST_ASSERT(pool->size == 4); |
130 CX_TEST_ASSERT(pool->size == 4); |