dovecot-1.1: t_get_bytes_available(): Return a bit less than is ...

dovecot at dovecot.org dovecot at dovecot.org
Fri Jun 13 00:36:29 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/2e712b753ae3
changeset: 7649:2e712b753ae3
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Jun 13 00:27:24 2008 +0300
description:
t_get_bytes_available(): Return a bit less than is available because some
space is wasted to alignmentation (and for other things when DEBUG enabled).

diffstat:

1 file changed, 8 insertions(+), 1 deletion(-)
src/lib/data-stack.c |    9 ++++++++-

diffs (19 lines):

diff -r 9ef860a7a9a8 -r 2e712b753ae3 src/lib/data-stack.c
--- a/src/lib/data-stack.c	Thu Jun 12 23:49:58 2008 +0300
+++ b/src/lib/data-stack.c	Fri Jun 13 00:27:24 2008 +0300
@@ -427,7 +427,14 @@ bool t_try_realloc(void *mem, size_t siz
 
 size_t t_get_bytes_available(void)
 {
-	return current_block->left;
+#ifndef DEBUG
+	const unsigned int extra = MEM_ALIGN_SIZE-1;
+#else
+	const unsigned int extra = MEM_ALIGN_SIZE-1 + SENTRY_COUNT +
+		MEM_ALIGN(sizeof(size_t));
+#endif
+	return current_block->left < extra ? current_block->left :
+		current_block->left - extra;
 }
 
 void *t_buffer_get(size_t size)


More information about the dovecot-cvs mailing list