From: Timo Sirainen Date: Mon, 5 Jul 2004 15:01:52 +0000 (+0300) Subject: pool_alloconly_free() can free the last allocation. X-Git-Tag: 1.1.alpha1~3820 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d3366e96ea7dbee2af95357c36b7844ebb62d934;p=thirdparty%2Fdovecot%2Fcore.git pool_alloconly_free() can free the last allocation. --HG-- branch : HEAD --- 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)