[dovecot-cvs] dovecot/src/lib mempool-alloconly.c,1.26,1.27

cras at procontrol.fi cras at procontrol.fi
Mon Jul 5 18:01:56 EEST 2004


Update of /home/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv27489/lib

Modified Files:
	mempool-alloconly.c 
Log Message:
pool_alloconly_free() can free the last allocation.



Index: mempool-alloconly.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/mempool-alloconly.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- mempool-alloconly.c	21 Sep 2003 17:55:36 -0000	1.26
+++ mempool-alloconly.c	5 Jul 2004 15:01:52 -0000	1.27
@@ -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)



More information about the dovecot-cvs mailing list