summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixCompat.c
diff options
context:
space:
mode:
authorandreas_kupries <andreas_kupries@noemail.net>2006-09-12 21:59:52 (GMT)
committerandreas_kupries <andreas_kupries@noemail.net>2006-09-12 21:59:52 (GMT)
commit6dfbae446b0284da80e0e20af8c472c94fc8a2b7 (patch)
treed891d59a457dc2eb56210ac52316be0a8ccf29e7 /unix/tclUnixCompat.c
parentbefc63f4e6be9d0b055e0e568be70cefc3e783bb (diff)
downloadtcl-6dfbae446b0284da80e0e20af8c472c94fc8a2b7.zip
tcl-6dfbae446b0284da80e0e20af8c472c94fc8a2b7.tar.gz
tcl-6dfbae446b0284da80e0e20af8c472c94fc8a2b7.tar.bz2
* unix/tclUnixCompat.c (PadBuffer): Fixed bug in calculation of
the increment needed to align the pointer, and added documentation explaining why the macro is implemented as it is. FossilOrigin-Name: ee4af820661e4226be8e089ace74953d8826118f
Diffstat (limited to 'unix/tclUnixCompat.c')
-rw-r--r--unix/tclUnixCompat.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/unix/tclUnixCompat.c b/unix/tclUnixCompat.c
index 37d6d05..d9deb8a 100644
--- a/unix/tclUnixCompat.c
+++ b/unix/tclUnixCompat.c
@@ -6,7 +6,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixCompat.c,v 1.7 2006/09/11 16:07:33 das Exp $
+ * RCS: @(#) $Id: tclUnixCompat.c,v 1.8 2006/09/12 21:59:53 andreas_kupries Exp $
*
*/
@@ -19,12 +19,18 @@
/*
* Used to pad structures at size'd boundaries
+ *
+ * This macro assumes that the pointer 'buffer' was created from an
+ * aligned pointer by adding the 'length'. If this 'length' was not a
+ * multiple of the 'size' the result is unaligned and PadBuffer
+ * corrects both the pointer, _and_ the 'length'. The latter means
+ * that future increments of 'buffer' by 'length' stay aligned.
*/
-#define PadBuffer(buffer, length, size) \
- if (((length) % (size))) { \
- (buffer) += ((length) % (size)); \
- (length) += ((length) % (size)); \
+#define PadBuffer(buffer, length, size) \
+ if (((length) % (size))) { \
+ (buffer) += ((size) - ((length) % (size))); \
+ (length) += ((size) - ((length) % (size))); \
}
/*