mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
src: improve and update ByteSource description
Clarify that external data must not be destroyed before the ByteSource that points to it, and that allocated data must have been allocated using OpenSSL's allocator (because it will be freed automatically, using OpenSSL's memory management functions). Also add a brief description of the new ByteSource::Builder class. PR-URL: https://github.com/nodejs/node/pull/43478 Reviewed-By: Darshan Sen <raisinten@gmail.com>
This commit is contained in:
1 parent
ba9b2f021f
commit
d3fc791c3d
1 file changed
+10
-3
+10
-3
@@ -100,9 +100,16 @@ Examples of these being used are pervasive through the `src/crypto` code.
|
||||
|
||||
The `ByteSource` class is a helper utility representing a _read-only_ byte
|
||||
array. Instances can either wrap external ("foreign") data sources, such as
|
||||
an `ArrayBuffer` (`v8::BackingStore`) or allocated data. If allocated data
|
||||
is used, then the allocation is freed automatically when the `ByteSource` is
|
||||
destroyed.
|
||||
an `ArrayBuffer` (`v8::BackingStore`), or allocated data.
|
||||
|
||||
* If a pointer to external data is used to create a `ByteSource`, that pointer
|
||||
must remain valid until the `ByteSource` is destroyed.
|
||||
* If allocated data is used, then it must have been allocated using OpenSSL's
|
||||
allocator. It will be freed automatically when the `ByteSource` is destroyed.
|
||||
|
||||
The `ByteSource::Builder` class can be used to allocate writable memory that can
|
||||
then be released as a `ByteSource`, making it read-only, or freed by destroying
|
||||
the `ByteSource::Builder` without releasing it as a `ByteSource`.
|
||||
|
||||
### `ArrayBufferOrViewContents`
|
||||
|
||||
|
||||
Reference in new issue
Block a user