aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoyeecheung <joyeec9h3@gmail.com>2016-12-07 01:31:53 +0800
committerAnna Henningsen <anna@addaleax.net>2016-12-09 15:39:24 +0100
commitbc335c0a8d68164fd978192409ab6c4986cfe374 (patch)
tree1d17f3744cc842d23be715671631c059fc518ea4
parentb8fc9a3c6af2aac2941144e93c24572bb706932d (diff)
downloadandroid-node-v8-bc335c0a8d68164fd978192409ab6c4986cfe374.tar.gz
android-node-v8-bc335c0a8d68164fd978192409ab6c4986cfe374.tar.bz2
android-node-v8-bc335c0a8d68164fd978192409ab6c4986cfe374.zip
doc: buffer allocation throws for negative size
PR-URL: https://github.com/nodejs/node/pull/10151 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
-rw-r--r--doc/api/buffer.md31
1 files changed, 15 insertions, 16 deletions
diff --git a/doc/api/buffer.md b/doc/api/buffer.md
index 016aa4ed8c..b9f8369335 100644
--- a/doc/api/buffer.md
+++ b/doc/api/buffer.md
@@ -392,9 +392,9 @@ deprecated: v6.0.0
* `size` {Integer} The desired length of the new `Buffer`
-Allocates a new `Buffer` of `size` bytes. The `size` must be less than or equal
-to the value of [`buffer.kMaxLength`]. Otherwise, a [`RangeError`] is thrown.
-A zero-length `Buffer` will be created if `size <= 0`.
+Allocates a new `Buffer` of `size` bytes. If the `size` is larger than
+[`buffer.kMaxLength`] or smaller than 0, a [`RangeError`] will be thrown.
+A zero-length `Buffer` will be created if `size` is 0.
Unlike [`ArrayBuffers`][`ArrayBuffer`], the underlying memory for `Buffer` instances
created in this way is *not initialized*. The contents of a newly created `Buffer`
@@ -470,9 +470,9 @@ const buf = Buffer.alloc(5);
console.log(buf);
```
-The `size` must be less than or equal to the value of [`buffer.kMaxLength`].
-Otherwise, a [`RangeError`] is thrown. A zero-length `Buffer` will be created if
-`size <= 0`.
+Allocates a new `Buffer` of `size` bytes. If the `size` is larger than
+[`buffer.kMaxLength`] or smaller than 0, a [`RangeError`] will be thrown.
+A zero-length `Buffer` will be created if `size` is 0.
If `fill` is specified, the allocated `Buffer` will be initialized by calling
[`buf.fill(fill)`][`buf.fill()`].
@@ -511,9 +511,9 @@ added: v5.10.0
* `size` {Integer} The desired length of the new `Buffer`
-Allocates a new *non-zero-filled* `Buffer` of `size` bytes. The `size` must
-be less than or equal to the value of [`buffer.kMaxLength`]. Otherwise, a
-[`RangeError`] is thrown. A zero-length `Buffer` will be created if `size <= 0`.
+Allocates a new `Buffer` of `size` bytes. If the `size` is larger than
+[`buffer.kMaxLength`] or smaller than 0, a [`RangeError`] will be thrown.
+A zero-length `Buffer` will be created if `size` is 0.
The underlying memory for `Buffer` instances created in this way is *not
initialized*. The contents of the newly created `Buffer` are unknown and
@@ -557,10 +557,9 @@ added: v5.10.0
* `size` {Integer} The desired length of the new `Buffer`
-Allocates a new *non-zero-filled* and non-pooled `Buffer` of `size` bytes. The
-`size` must be less than or equal to the value of [`buffer.kMaxLength`].
-Otherwise, a [`RangeError`] is thrown. A zero-length `Buffer` will be created if
-`size <= 0`.
+Allocates a new `Buffer` of `size` bytes. If the `size` is larger than
+[`buffer.kMaxLength`] or smaller than 0, a [`RangeError`] will be thrown.
+A zero-length `Buffer` will be created if `size` is 0.
The underlying memory for `Buffer` instances created in this way is *not
initialized*. The contents of the newly created `Buffer` are unknown and
@@ -2390,9 +2389,9 @@ deprecated: v6.0.0
* `size` {Integer} The desired length of the new `SlowBuffer`
-Allocates a new `SlowBuffer` of `size` bytes. The `size` must be less than
-or equal to the value of [`buffer.kMaxLength`]. Otherwise, a [`RangeError`] is
-thrown. A zero-length `Buffer` will be created if `size <= 0`.
+Allocates a new `Buffer` of `size` bytes. If the `size` is larger than
+[`buffer.kMaxLength`] or smaller than 0, a [`RangeError`] will be thrown.
+A zero-length `Buffer` will be created if `size` is 0.
The underlying memory for `SlowBuffer` instances is *not initialized*. The
contents of a newly created `SlowBuffer` are unknown and could contain