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>
This commit is contained in:
parent
b8fc9a3c6a
commit
bc335c0a8d
@ -392,9 +392,9 @@ deprecated: v6.0.0
|
|||||||
|
|
||||||
* `size` {Integer} The desired length of the new `Buffer`
|
* `size` {Integer} The desired length of the new `Buffer`
|
||||||
|
|
||||||
Allocates a new `Buffer` of `size` bytes. The `size` must be less than or equal
|
Allocates a new `Buffer` of `size` bytes. If the `size` is larger than
|
||||||
to the value of [`buffer.kMaxLength`]. Otherwise, a [`RangeError`] is thrown.
|
[`buffer.kMaxLength`] or smaller than 0, a [`RangeError`] will be thrown.
|
||||||
A zero-length `Buffer` will be created if `size <= 0`.
|
A zero-length `Buffer` will be created if `size` is 0.
|
||||||
|
|
||||||
Unlike [`ArrayBuffers`][`ArrayBuffer`], the underlying memory for `Buffer` instances
|
Unlike [`ArrayBuffers`][`ArrayBuffer`], the underlying memory for `Buffer` instances
|
||||||
created in this way is *not initialized*. The contents of a newly created `Buffer`
|
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);
|
console.log(buf);
|
||||||
```
|
```
|
||||||
|
|
||||||
The `size` must be less than or equal to the value of [`buffer.kMaxLength`].
|
Allocates a new `Buffer` of `size` bytes. If the `size` is larger than
|
||||||
Otherwise, a [`RangeError`] is thrown. A zero-length `Buffer` will be created if
|
[`buffer.kMaxLength`] or smaller than 0, a [`RangeError`] will be thrown.
|
||||||
`size <= 0`.
|
A zero-length `Buffer` will be created if `size` is 0.
|
||||||
|
|
||||||
If `fill` is specified, the allocated `Buffer` will be initialized by calling
|
If `fill` is specified, the allocated `Buffer` will be initialized by calling
|
||||||
[`buf.fill(fill)`][`buf.fill()`].
|
[`buf.fill(fill)`][`buf.fill()`].
|
||||||
@ -511,9 +511,9 @@ added: v5.10.0
|
|||||||
|
|
||||||
* `size` {Integer} The desired length of the new `Buffer`
|
* `size` {Integer} The desired length of the new `Buffer`
|
||||||
|
|
||||||
Allocates a new *non-zero-filled* `Buffer` of `size` bytes. The `size` must
|
Allocates a new `Buffer` of `size` bytes. If the `size` is larger than
|
||||||
be less than or equal to the value of [`buffer.kMaxLength`]. Otherwise, a
|
[`buffer.kMaxLength`] or smaller than 0, a [`RangeError`] will be thrown.
|
||||||
[`RangeError`] is thrown. A zero-length `Buffer` will be created if `size <= 0`.
|
A zero-length `Buffer` will be created if `size` is 0.
|
||||||
|
|
||||||
The underlying memory for `Buffer` instances created in this way is *not
|
The underlying memory for `Buffer` instances created in this way is *not
|
||||||
initialized*. The contents of the newly created `Buffer` are unknown and
|
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`
|
* `size` {Integer} The desired length of the new `Buffer`
|
||||||
|
|
||||||
Allocates a new *non-zero-filled* and non-pooled `Buffer` of `size` bytes. The
|
Allocates a new `Buffer` of `size` bytes. If the `size` is larger than
|
||||||
`size` must be less than or equal to the value of [`buffer.kMaxLength`].
|
[`buffer.kMaxLength`] or smaller than 0, a [`RangeError`] will be thrown.
|
||||||
Otherwise, a [`RangeError`] is thrown. A zero-length `Buffer` will be created if
|
A zero-length `Buffer` will be created if `size` is 0.
|
||||||
`size <= 0`.
|
|
||||||
|
|
||||||
The underlying memory for `Buffer` instances created in this way is *not
|
The underlying memory for `Buffer` instances created in this way is *not
|
||||||
initialized*. The contents of the newly created `Buffer` are unknown and
|
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`
|
* `size` {Integer} The desired length of the new `SlowBuffer`
|
||||||
|
|
||||||
Allocates a new `SlowBuffer` of `size` bytes. The `size` must be less than
|
Allocates a new `Buffer` of `size` bytes. If the `size` is larger than
|
||||||
or equal to the value of [`buffer.kMaxLength`]. Otherwise, a [`RangeError`] is
|
[`buffer.kMaxLength`] or smaller than 0, a [`RangeError`] will be thrown.
|
||||||
thrown. A zero-length `Buffer` will be created if `size <= 0`.
|
A zero-length `Buffer` will be created if `size` is 0.
|
||||||
|
|
||||||
The underlying memory for `SlowBuffer` instances is *not initialized*. The
|
The underlying memory for `SlowBuffer` instances is *not initialized*. The
|
||||||
contents of a newly created `SlowBuffer` are unknown and could contain
|
contents of a newly created `SlowBuffer` are unknown and could contain
|
||||||
|
Loading…
x
Reference in New Issue
Block a user