diff options
author | James M Snell <jasnell@gmail.com> | 2016-01-25 15:00:06 -0800 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2016-03-16 08:34:02 -0700 |
commit | 85ab4a5f1281c4e1dd06450ac7bd3250326267fa (patch) | |
tree | 7a51edfc5d6efc231cf821d575c9ca4a26d0545f /test/parallel/test-http-parser-bad-ref.js | |
parent | 90a5fc20be22b4278a01bc58acba0cb732da0140 (diff) | |
download | android-node-v8-85ab4a5f1281c4e1dd06450ac7bd3250326267fa.tar.gz android-node-v8-85ab4a5f1281c4e1dd06450ac7bd3250326267fa.tar.bz2 android-node-v8-85ab4a5f1281c4e1dd06450ac7bd3250326267fa.zip |
buffer: add .from(), .alloc() and .allocUnsafe()
Several changes:
* Soft-Deprecate Buffer() constructors
* Add `Buffer.from()`, `Buffer.alloc()`, and `Buffer.allocUnsafe()`
* Add `--zero-fill-buffers` command line option
* Add byteOffset and length to `new Buffer(arrayBuffer)` constructor
* buffer.fill('') previously had no effect, now zero-fills
* Update the docs
PR-URL: https://github.com/nodejs/node/pull/4682
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Diffstat (limited to 'test/parallel/test-http-parser-bad-ref.js')
-rw-r--r-- | test/parallel/test-http-parser-bad-ref.js | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/test/parallel/test-http-parser-bad-ref.js b/test/parallel/test-http-parser-bad-ref.js index 545a9c1fef..b7f132a3ea 100644 --- a/test/parallel/test-http-parser-bad-ref.js +++ b/test/parallel/test-http-parser-bad-ref.js @@ -17,7 +17,7 @@ var headersComplete = 0; var messagesComplete = 0; function flushPool() { - new Buffer(Buffer.poolSize - 1); + Buffer.allocUnsafe(Buffer.poolSize - 1); gc(); } @@ -49,7 +49,7 @@ function demoBug(part1, part2) { // We use a function to eliminate references to the Buffer b // We want b to be GCed. The parser will hold a bad reference to it. (function() { - var b = Buffer(part1); + var b = Buffer.from(part1); flushPool(); console.log('parse the first part of the message'); @@ -59,7 +59,7 @@ function demoBug(part1, part2) { flushPool(); (function() { - var b = Buffer(part2); + var b = Buffer.from(part2); console.log('parse the second part of the message'); parser.execute(b, 0, b.length); |