dovecot-2.2: lib: data-stack - t_try_realloc get alloc size righ...

dovecot at dovecot.org dovecot at dovecot.org
Mon Jul 28 13:54:29 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/beb56c7124ab
changeset: 17648:beb56c7124ab
user:      Phil Carmody <phil at dovecot.fi>
date:      Mon Jul 28 16:45:33 2014 +0300
description:
lib: data-stack - t_try_realloc get alloc size right in DEBUG builds
Also introduce a helper variable for the common expression for readability.

Signed-off-by: Phil Carmody <phil at dovecot.fi>

diffstat:

 src/lib/data-stack.c |  12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diffs (23 lines):

diff -r 5567eedee0c2 -r beb56c7124ab src/lib/data-stack.c
--- a/src/lib/data-stack.c	Mon Jul 28 16:45:33 2014 +0300
+++ b/src/lib/data-stack.c	Mon Jul 28 16:45:33 2014 +0300
@@ -467,11 +467,15 @@
 	after_last_alloc = data_stack_after_last_alloc(current_block);
 	if (after_last_alloc - last_alloc_size == mem) {
 		/* yeah, see if we have space to grow */
-		size = MEM_ALIGN(size);
-		if (current_block->left >= size - last_alloc_size) {
+		size_t new_alloc_size, alloc_growth;
+
+		new_alloc_size = ALLOC_SIZE(size);
+		alloc_growth = (new_alloc_size - last_alloc_size);
+		if (current_block->left >= alloc_growth) {
 			/* just shrink the available size */
-			current_block->left -= size - last_alloc_size;
-			current_frame_block->last_alloc_size[frame_pos] = size;
+			current_block->left -= alloc_growth;
+			current_frame_block->last_alloc_size[frame_pos] =
+				new_alloc_size;
 			return TRUE;
 		}
 	}


More information about the dovecot-cvs mailing list