summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2013-06-27 03:18:41 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2013-06-27 03:22:05 +0200
commitcf6acf2a1a8717eb55aec8df79121ee6a75611f4 (patch)
tree0795e3516e86e05b3b983b41264378267e72df5b
parent2a8c5ddc468670498b98231ea5c2464fd7e5c858 (diff)
downloadnode-new-cf6acf2a1a8717eb55aec8df79121ee6a75611f4.tar.gz
buffer: add comment explaining buffer alignment
Avoids alignment issues (unaligned loads/stores) on ARM. Originally added in commit 285d8c6. Fixes #3030.
-rw-r--r--lib/buffer.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/buffer.js b/lib/buffer.js
index 000c54b3a8..51406b6ed6 100644
--- a/lib/buffer.js
+++ b/lib/buffer.js
@@ -199,8 +199,8 @@ function Buffer(subject, encoding, offset) {
if (!pool || pool.length - pool.used < this.length) allocPool();
this.parent = pool;
this.offset = pool.used;
- pool.used += this.length;
- if (pool.used & 7) pool.used = (pool.used + 8) & ~7;
+ // Align on 8 byte boundary to avoid alignment issues on ARM.
+ pool.used = (pool.used + this.length + 7) & ~7;
} else {
// Zero-length buffer