Browse Source

doc: minor copy improvement in buffer.markdown

PR-URL: https://github.com/nodejs/node/pull/5833
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
process-exit-stdio-flushing
James M Snell 9 years ago
parent
commit
a0579c0dc7
  1. 35
      doc/api/buffer.markdown

35
doc/api/buffer.markdown

@ -103,14 +103,13 @@ use the shared internal memory pool.
### The `--zero-fill-buffers` command line option ### The `--zero-fill-buffers` command line option
Node.js can be started using the `--zero-fill-buffers` command line option to Node.js can be started using the `--zero-fill-buffers` command line option to
force all newly allocated `Buffer` and `SlowBuffer` instances created using force all newly allocated `Buffer` instances created using either
either `new Buffer(size)`, `Buffer.allocUnsafe(size)`, `new Buffer(size)`, `Buffer.allocUnsafe(size)`, `Buffer.allocUnsafeSlow(size)`
`Buffer.allocUnsafeSlow(size)` or `new SlowBuffer(size)` to be *automatically or `new SlowBuffer(size)` to be *automatically zero-filled* upon creation. Use
zero-filled* upon creation. Use of this flag *changes the default behavior* of of this flag *changes the default behavior* of these methods and *can have a
these methods and *can have a significant impact* on performance. Use of the significant impact* on performance. Use of the `--zero-fill-buffers` option is
`--zero-fill-buffers` option is recommended only when absolutely necessary to recommended only when absolutely necessary to enforce that newly allocated
enforce that newly allocated `Buffer` instances cannot contain potentially `Buffer` instances cannot contain potentially sensitive data.
sensitive data.
``` ```
$ node --zero-fill-buffers $ node --zero-fill-buffers
@ -342,8 +341,8 @@ console.log(buf);
Allocates a new `Buffer` of `size` bytes. The `size` must be less than Allocates a new `Buffer` of `size` bytes. The `size` must be less than
or equal to the value of `require('buffer').kMaxLength` (on 64-bit or equal to the value of `require('buffer').kMaxLength` (on 64-bit
architectures, `kMaxLength` is `(2^31)-1`). Otherwise, a [`RangeError`][] is architectures, `kMaxLength` is `(2^31)-1`). Otherwise, a [`RangeError`][] is
thrown. If a `size` less than 0 is specified, a zero-length Buffer will be thrown. A zero-length Buffer will be created if a `size` less than or equal to
created. 0 is specified.
Unlike `ArrayBuffers`, the underlying memory for `Buffer` instances created in Unlike `ArrayBuffers`, the underlying memory for `Buffer` instances created in
this way is *not initialized*. The contents of a newly created `Buffer` are this way is *not initialized*. The contents of a newly created `Buffer` are
@ -400,8 +399,8 @@ console.log(buf);
The `size` must be less than or equal to the value of The `size` must be less than or equal to the value of
`require('buffer').kMaxLength` (on 64-bit architectures, `kMaxLength` is `require('buffer').kMaxLength` (on 64-bit architectures, `kMaxLength` is
`(2^31)-1`). Otherwise, a [`RangeError`][] is thrown. If a `size` less than 0 `(2^31)-1`). Otherwise, a [`RangeError`][] is thrown. A zero-length Buffer will
is specified, a zero-length `Buffer` will be created. be created if a `size` less than or equal to 0 is specified.
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)`. See [`buf.fill()`][] for more information. `buf.fill(fill)`. See [`buf.fill()`][] for more information.
@ -434,8 +433,8 @@ A `TypeError` will be thrown if `size` is not a number.
Allocates a new *non-zero-filled* `Buffer` of `size` bytes. The `size` must Allocates a new *non-zero-filled* `Buffer` of `size` bytes. The `size` must
be less than or equal to the value of `require('buffer').kMaxLength` (on 64-bit be less than or equal to the value of `require('buffer').kMaxLength` (on 64-bit
architectures, `kMaxLength` is `(2^31)-1`). Otherwise, a [`RangeError`][] is architectures, `kMaxLength` is `(2^31)-1`). Otherwise, a [`RangeError`][] is
thrown. If a `size` less than 0 is specified, a zero-length `Buffer` will be thrown. A zero-length Buffer will be created if a `size` less than or equal to
created. 0 is specified.
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
@ -476,8 +475,8 @@ additional performance that `Buffer.allocUnsafe(size)` provides.
Allocates a new *non-zero-filled* and non-pooled `Buffer` of `size` bytes. The 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 `size` must be less than or equal to the value of
`require('buffer').kMaxLength` (on 64-bit architectures, `kMaxLength` is `require('buffer').kMaxLength` (on 64-bit architectures, `kMaxLength` is
`(2^31)-1`). Otherwise, a [`RangeError`][] is thrown. If a `size` less than 0 `(2^31)-1`). Otherwise, a [`RangeError`][] is thrown. A zero-length Buffer will
is specified, a zero-length `Buffer` will be created. be created if a `size` less than or equal to 0 is specified.
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
@ -1824,8 +1823,8 @@ has observed undue memory retention in their applications.
Allocates a new `SlowBuffer` of `size` bytes. The `size` must be less than Allocates a new `SlowBuffer` of `size` bytes. The `size` must be less than
or equal to the value of `require('buffer').kMaxLength` (on 64-bit or equal to the value of `require('buffer').kMaxLength` (on 64-bit
architectures, `kMaxLength` is `(2^31)-1`). Otherwise, a [`RangeError`][] is architectures, `kMaxLength` is `(2^31)-1`). Otherwise, a [`RangeError`][] is
thrown. If a `size` less than 0 is specified, a zero-length `SlowBuffer` will be thrown. A zero-length Buffer will be created if a `size` less than or equal to
created. 0 is specified.
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…
Cancel
Save