dovecot-2.1: data-stack: Fixed calling t_push()/t_malloc() befor...

dovecot at dovecot.org dovecot at dovecot.org
Mon Mar 26 16:23:35 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/e79496bb09f5
changeset: 14348:e79496bb09f5
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Mar 26 15:34:46 2012 +0300
description:
data-stack: Fixed calling t_push()/t_malloc() before data_stack_init().

diffstat:

 src/lib/data-stack.c |  36 ++++++++++++++++++++----------------
 1 files changed, 20 insertions(+), 16 deletions(-)

diffs (58 lines):

diff -r 8699f3d3c1e4 -r e79496bb09f5 src/lib/data-stack.c
--- a/src/lib/data-stack.c	Sat Mar 24 14:21:59 2012 +0200
+++ b/src/lib/data-stack.c	Mon Mar 26 15:34:46 2012 +0300
@@ -64,7 +64,11 @@
 
 static struct stack_block *last_buffer_block;
 static size_t last_buffer_size;
+#ifdef DEBUG
+static bool clean_after_pop = TRUE;
+#else
 static bool clean_after_pop = FALSE;
+#endif
 static bool outofmem = FALSE;
 
 static union {
@@ -490,26 +494,26 @@
 
 void data_stack_init(void)
 {
-#ifdef DEBUG
-	clean_after_pop = TRUE;
-#endif
-	if (data_stack_frame == 0) {
-		data_stack_frame = 1;
+	if (data_stack_frame > 0) {
+		/* already initialized (we did auto-initialization in
+		   t_malloc/t_push) */
+		return;
+	}
+	data_stack_frame = 1;
 
-		outofmem_area.block.size = outofmem_area.block.left =
-			sizeof(outofmem_area) - sizeof(outofmem_area.block);
+	outofmem_area.block.size = outofmem_area.block.left =
+		sizeof(outofmem_area) - sizeof(outofmem_area.block);
 
-		current_block = mem_block_alloc(INITIAL_STACK_SIZE);
-		current_block->left = current_block->size;
-		current_block->next = NULL;
+	current_block = mem_block_alloc(INITIAL_STACK_SIZE);
+	current_block->left = current_block->size;
+	current_block->next = NULL;
 
-		current_frame_block = NULL;
-		unused_frame_blocks = NULL;
-		frame_pos = BLOCK_FRAME_COUNT-1;
+	current_frame_block = NULL;
+	unused_frame_blocks = NULL;
+	frame_pos = BLOCK_FRAME_COUNT-1;
 
-		last_buffer_block = NULL;
-		last_buffer_size = 0;
-	}
+	last_buffer_block = NULL;
+	last_buffer_size = 0;
 
 	t_push();
 }


More information about the dovecot-cvs mailing list