Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ function createPool() {
}


function alignPool() {
// Ensure aligned slices
if (poolOffset & 0x7) {
poolOffset |= 0x7;
poolOffset++;
}
}


function Buffer(arg) {
// Common case.
if (typeof arg === 'number') {
Expand Down Expand Up @@ -66,6 +75,7 @@ function allocate(size) {
createPool();
var b = binding.slice(allocPool, poolOffset, poolOffset + size);
poolOffset += size;
alignPool();
return b;
} else {
return binding.create(size);
Expand All @@ -86,6 +96,7 @@ function fromString(string, encoding) {
var actual = allocPool.write(string, poolOffset, encoding);
var b = binding.slice(allocPool, poolOffset, poolOffset + actual);
poolOffset += actual;
alignPool();
return b;
}

Expand Down