Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: added some warnings for buffer and array buffer factory method. #929

Merged
merged 3 commits into from
Mar 22, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/array_buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ The `Napi::ArrayBuffer` instance does not assume ownership for the data and
expects it to be valid for the lifetime of the instance. Since the
`Napi::ArrayBuffer` is subject to garbage collection this overload is only
suitable for data which is static and never needs to be freed.
This factory method will not provide the caller with an opportunity to free the
data when hen the `Napi::ArrayBuffer` gets garbage-collected. If you need to
NickNaso marked this conversation as resolved.
Show resolved Hide resolved
free the data retained by the `Napi::ArrayBuffer` object please use other
variants of the `Napi::ArrayBuffer::New` factory method that accept
`Napi::Finalizer`, which is a function that will be invoked when the
NickNaso marked this conversation as resolved.
Show resolved Hide resolved
`Napi::ArrayBuffer` object has been destroyed.

```cpp
static Napi::ArrayBuffer Napi::ArrayBuffer::New(napi_env env, void* externalData, size_t byteLength);
Expand Down
6 changes: 6 additions & 0 deletions doc/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ The `Napi::Buffer` object does not assume ownership for the data and expects it
valid for the lifetime of the object. Since the `Napi::Buffer` is subject to garbage
collection this overload is only suitable for data which is static and never
needs to be freed.
This factory method will not provide the caller with an opportunity to free the
data when the `Napi::Buffer` gets garbage-collected. If you need to free the
data retained by the `Napi::Buffer` object please use other variants of the
`Napi::Buffer::New` factory method that accept `Napi::Finalizer`, which is a
function that will be invoked when the `Napi::Buffer` object has been
destroyed.

```cpp
static Napi::Buffer<T> Napi::Buffer::New(napi_env env, T* data, size_t length);
Expand Down