From d3366e96ea7dbee2af95357c36b7844ebb62d934 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Mon, 5 Jul 2004 18:01:52 +0300 Subject: [PATCH] pool_alloconly_free() can free the last allocation. --HG-- branch : HEAD --- src/lib/mempool-alloconly.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/lib/mempool-alloconly.c b/src/lib/mempool-alloconly.c index 761488c329..a7d23be981 100644 --- a/src/lib/mempool-alloconly.c +++ b/src/lib/mempool-alloconly.c @@ -186,10 +186,17 @@ static void *pool_alloconly_malloc(pool_t pool, size_t size) return mem; } -static void pool_alloconly_free(pool_t pool __attr_unused__, - void *mem __attr_unused__) +static void pool_alloconly_free(pool_t pool, void *mem) { - /* ignore */ + struct alloconly_pool *apool = (struct alloconly_pool *) pool; + + /* we can free only the last allocation */ + if (POOL_BLOCK_DATA(apool->block) + + (apool->block->size - apool->block->left - + apool->block->last_alloc_size) == mem) { + apool->block->left += apool->block->last_alloc_size; + apool->block->last_alloc_size = 0; + } } static int pool_try_grow(struct alloconly_pool *apool, void *mem, size_t size) -- 2.47.3