MCPcopy Create free account
hub / github.com/nodejs/node-addon-api / CreateOrCopyExternalBuffer

Function CreateOrCopyExternalBuffer

test/buffer_new_or_copy-inl.h:4–19  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2// defined.
3
4Value CreateOrCopyExternalBuffer(const CallbackInfo& info) {
5 finalizeCount = 0;
6
7 InitData(testData, testLength);
8 Buffer<uint16_t> buffer =
9 Buffer<uint16_t>::NewOrCopy(info.Env(), testData, testLength);
10
11 if (buffer.Length() != testLength) {
12 Error::New(info.Env(), "Incorrect buffer length.")
13 .ThrowAsJavaScriptException();
14 return Value();
15 }
16
17 VerifyData(buffer.Data(), testLength);
18 return buffer;
19}
20
21Value CreateOrCopyExternalBufferWithFinalize(const CallbackInfo& info) {
22 finalizeCount = 0;

Callers

nothing calls this directly

Calls 7

EnvMethod · 0.80
LengthMethod · 0.80
DataMethod · 0.80
InitDataFunction · 0.70
VerifyDataFunction · 0.70
ValueClass · 0.50

Tested by

no test coverage detected