changeset 2286:ee918986f94e HEAD

pool_alloconly_free() can free the last allocation.
author Timo Sirainen <tss@iki.fi>
date Mon, 05 Jul 2004 18:01:52 +0300
parents afb81e31b989
children df0b936ae3ed
files src/lib/mempool-alloconly.c
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/mempool-alloconly.c	Mon Jul 05 01:19:49 2004 +0300
+++ b/src/lib/mempool-alloconly.c	Mon Jul 05 18:01:52 2004 +0300
@@ -186,10 +186,17 @@
 	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)