dovecot-1.1: DEBUG: Fixes to calculating minimum initial pool si...

dovecot at dovecot.org dovecot at dovecot.org
Sun May 4 22:35:40 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/33d6be3b5c01
changeset: 7491:33d6be3b5c01
user:      Timo Sirainen <tss at iki.fi>
date:      Sun May 04 22:35:35 2008 +0300
description:
DEBUG: Fixes to calculating minimum initial pool size in debug mode.

diffstat:

1 file changed, 9 insertions(+), 7 deletions(-)
src/lib/mempool-alloconly.c |   16 +++++++++-------

diffs (47 lines):

diff -r e935b36b8b65 -r 33d6be3b5c01 src/lib/mempool-alloconly.c
--- a/src/lib/mempool-alloconly.c	Sun May 04 22:05:21 2008 +0300
+++ b/src/lib/mempool-alloconly.c	Sun May 04 22:35:35 2008 +0300
@@ -48,6 +48,7 @@ struct pool_block {
 #  define CLEAR_CHR 0xde
 #  define SENTRY_COUNT 8
 #else
+#  define SENTRY_COUNT 0
 #  define CLEAR_CHR 0
 #endif
 
@@ -122,11 +123,12 @@ pool_t pool_alloconly_create(const char 
 pool_t pool_alloconly_create(const char *name ATTR_UNUSED, size_t size)
 {
 	struct alloconly_pool apool, *new_apool;
-	size_t min_alloc = MEM_ALIGN(sizeof(struct alloconly_pool)) +
-		SIZEOF_POOLBLOCK;
-
-#ifdef DEBUG
-	min_alloc += MEM_ALIGN(strlen(name) + 1 + SENTRY_COUNT);
+	size_t min_alloc = SIZEOF_POOLBLOCK +
+		MEM_ALIGN(sizeof(struct alloconly_pool) + SENTRY_COUNT);
+
+#ifdef DEBUG
+	min_alloc += MEM_ALIGN(strlen(name) + 1 + SENTRY_COUNT) +
+		sizeof(size_t)*2;
 #endif
 
 	/* create a fake alloconly_pool so we can call block_alloc() */
@@ -141,8 +143,6 @@ pool_t pool_alloconly_create(const char 
 	/* now allocate the actual alloconly_pool from the created block */
 	new_apool = p_new(&apool.pool, struct alloconly_pool, 1);
 	*new_apool = apool;
-	/* the pool allocation must be from the first block */
-	i_assert(apool.block->prev == NULL);
 #ifdef DEBUG
 	if (strncmp(name, MEMPOOL_GROWING, strlen(MEMPOOL_GROWING)) == 0) {
 		name += strlen(MEMPOOL_GROWING);
@@ -154,6 +154,8 @@ pool_t pool_alloconly_create(const char 
 	new_apool->base_size = new_apool->block->size - new_apool->block->left;
 	new_apool->block->last_alloc_size = 0;
 #endif
+	/* the first pool allocations must be from the first block */
+	i_assert(new_apool->block->prev == NULL);
 
 	return &new_apool->pool;
 }


More information about the dovecot-cvs mailing list