-
-
Notifications
You must be signed in to change notification settings - Fork 12
Description
I'm attempting to call napi_create_arraybuffer from https://github.com/nodejs/node-addon-api/blob/294a43f8c6a4c79b3295a8f1b83d4782d44cfe74/napi-inl.h#L1998.
However, writing to the memory pointed to by the output data void pointer does not correctly update the state of the arraybuffer in javascript. I was able to successfully use napi_create_external_arraybuffer from emnapi by passing in the desired buffer during ArrayBuffer construction rather than mutating the allocated buffer after construction.
Any ideas what might be going wrong? I didn't really understand the logic in emnapiExternalMemory.getArrayBufferPointer. It appears to be correct if you want to read the buffer, but since it makes a copy, I don't see how it could properly provide write access to the caller.
According to the napi docs https://nodejs.org/api/n-api.html#napi_create_arraybuffer:
The underlying buffer is optionally returned back to the caller in case the caller wants to directly
manipulate the buffer. This buffer can only be written to directly from native code.
Thanks!