changeset 7849:9a00bd31ca99 HEAD

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).
author Timo Sirainen <tss@iki.fi>
date Fri, 13 Jun 2008 00:27:24 +0300
parents a1fd8b29f629
children 7f9f7fc02359
files src/lib/data-stack.c
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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 @@
 
 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)