-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: handle no support for external buffers
PR-URL: #1273 Reviewed-By: Michael Dawson <midawson@redhat.com
- Loading branch information
1 parent
61b8e28
commit b16c762
Showing
12 changed files
with
456 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# External Buffer | ||
|
||
**Some runtimes other than Node.js have dropped support for external buffers**. | ||
On runtimes other than Node.js, node-api methods may return | ||
`napi_no_external_buffers_allowed` to indicate that external | ||
buffers are not supported. One such runtime is Electron as | ||
described in this issue | ||
[electron/issues/35801](https://github.com/electron/electron/issues/35801). | ||
|
||
In order to maintain broadest compatibility with all runtimes, | ||
you may define `NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED` in your addon before | ||
includes for the node-api and node-addon-api headers. Doing so will hide the | ||
functions that create external buffers. This will ensure a compilation error | ||
occurs if you accidentally use one of these methods. | ||
|
||
In node-addon-api, the `Napi::Buffer::NewOrCopy` provides a convenient way to | ||
create an external buffer, or allocate a new buffer and copy the data when the | ||
external buffer is not supported. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.