]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
t_get_bytes_available(): Return a bit less than is available because some
authorTimo Sirainen <tss@iki.fi>
Thu, 12 Jun 2008 21:27:24 +0000 (00:27 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 12 Jun 2008 21:27:24 +0000 (00:27 +0300)
space is wasted to alignmentation (and for other things when DEBUG enabled).

--HG--
branch : HEAD

src/lib/data-stack.c

index 2824958c122546bdfc339cef45d78ab381b58d45..57dc8604f28664783dedab55df23b4de7061d42c 100644 (file)
@@ -427,7 +427,14 @@ bool t_try_realloc(void *mem, size_t size)
 
 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)