/* -*- mode: C; c-basic-offset: 4 -*- */ #ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved." #include "test.h" #include #include #include "toku_assert.h" #include "memory.h" #include "mempool.h" static void test_mempool_limits (size_t size) { void *base = malloc(size); struct mempool mempool; toku_mempool_init(&mempool, base, size); size_t i; for (i=0;; i++) { void *vp = toku_mempool_malloc(&mempool, 1, 1); if (vp == 0) break; } assert(i == size); toku_mempool_fini(&mempool); free(base); } static void test_mempool_malloc_mfree (size_t size) { void *base = malloc(size); struct mempool mempool; toku_mempool_init(&mempool, base, size); void *vp[size]; size_t i; for (i=0;; i++) { void *tp = toku_mempool_malloc(&mempool, 1, 1); if (tp == 0) break; assert(i < size); vp[i] = tp; } assert(i == size); for (i=0; i