I am writing a Node Addon Function That returns a Promise, I have code like this.
size_t outbufsize = 1000;
context->data.size = outbufsize;
context->data.data = new char[outbufsize];
When I finish work.
context->deffered.Resolve(Napi::ArrayBuffer::New(env, context->data.data, context->data.size));
Do I need to delete pointer "context->data.data"? if I delete this pointer. I get an undefine behavior ArrayBuffer on the Javascript side. But if I don't delete the pointer, I don't know if the memory is freed or not?
I think I should return the Buffer instead of ArrayBuffer.
as the document say---that accept Napi::Finalizer, which is a function that will be invoked when the Napi::Buffer object has been destroyed.