Skip to content

Commit d3fc791

Browse files
tniessentargos
authored andcommitted
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: #43478 Reviewed-By: Darshan Sen <[email protected]>
1 parent ba9b2f0 commit d3fc791

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/crypto/README.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,16 @@ Examples of these being used are pervasive through the `src/crypto` code.
100100

101101
The `ByteSource` class is a helper utility representing a _read-only_ byte
102102
array. Instances can either wrap external ("foreign") data sources, such as
103-
an `ArrayBuffer` (`v8::BackingStore`) or allocated data. If allocated data
104-
is used, then the allocation is freed automatically when the `ByteSource` is
105-
destroyed.
103+
an `ArrayBuffer` (`v8::BackingStore`), or allocated data.
104+
105+
* If a pointer to external data is used to create a `ByteSource`, that pointer
106+
must remain valid until the `ByteSource` is destroyed.
107+
* If allocated data is used, then it must have been allocated using OpenSSL's
108+
allocator. It will be freed automatically when the `ByteSource` is destroyed.
109+
110+
The `ByteSource::Builder` class can be used to allocate writable memory that can
111+
then be released as a `ByteSource`, making it read-only, or freed by destroying
112+
the `ByteSource::Builder` without releasing it as a `ByteSource`.
106113

107114
### `ArrayBufferOrViewContents`
108115

0 commit comments

Comments
 (0)