summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandreas_kupries <akupries@shaw.ca>2006-09-12 22:05:02 (GMT)
committerandreas_kupries <akupries@shaw.ca>2006-09-12 22:05:02 (GMT)
commitb45164f6b072a2793e896f53449f81ba6f73f981 (patch)
tree6de91b9fbb165378373cabb64e14af69d10297a3
parentb452b8cae9b90c3b781f0a67f5c43d170df1aa8d (diff)
downloadtcl-b45164f6b072a2793e896f53449f81ba6f73f981.zip
tcl-b45164f6b072a2793e896f53449f81ba6f73f981.tar.gz
tcl-b45164f6b072a2793e896f53449f81ba6f73f981.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.
-rw-r--r--ChangeLog6
-rw-r--r--unix/tclUnixCompat.c16
2 files changed, 17 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 09b9fcc..029620a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-09-12 Andreas Kupries <andreask@activestate.com>
+
+ * 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.
+
2006-09-11 Andreas Kupries <andreask@activestate.com>
* tests/msgcat.test: Bumped version in auxiliary files as well.
diff --git a/unix/tclUnixCompat.c b/unix/tclUnixCompat.c
index 84684b5..7e419cf 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.1.2.9 2006/09/11 16:07:45 das Exp $
+ * RCS: @(#) $Id: tclUnixCompat.c,v 1.1.2.10 2006/09/12 22:05:03 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))); \
}
/*