var isArray = require('is-array')
exports.Buffer = Buffer
-exports.SlowBuffer = Buffer
+exports.SlowBuffer = SlowBuffer
exports.INSPECT_MAX_BYTES = 50
Buffer.poolSize = 8192 // not used by this implementation
var kMaxLength = 0x3fffffff
+var rootParent = {}
/**
* If `Buffer.TYPED_ARRAY_SUPPORT`:
}
}
+ if (length > 0 && length <= Buffer.poolSize)
+ buf.parent = rootParent
+
+ return buf
+}
+
+function SlowBuffer(subject, encoding, noZero) {
+ if (!(this instanceof SlowBuffer))
+ return new SlowBuffer(subject, encoding, noZero)
+
+ var buf = new Buffer(subject, encoding, noZero)
+ delete buf.parent
return buf
}
if (end < start)
end = start
+ var newBuf
if (Buffer.TYPED_ARRAY_SUPPORT) {
- return Buffer._augment(this.subarray(start, end))
+ newBuf = Buffer._augment(this.subarray(start, end))
} else {
var sliceLen = end - start
- var newBuf = new Buffer(sliceLen, undefined, true)
+ newBuf = new Buffer(sliceLen, undefined, true)
for (var i = 0; i < sliceLen; i++) {
newBuf[i] = this[i + start]
}
- return newBuf
}
+
+ if (newBuf.length)
+ newBuf.parent = this.parent || this
+
+ return newBuf
}
/*