Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-02-19 00:58:27 +0300
committerAnna Henningsen <anna@addaleax.net>2019-02-25 04:01:11 +0300
commit84e02b178ad14fae0df2a514e8a39bfa50ffdc2d (patch)
treeddc0435b6bd0b7811e0bf47687777c56b2857fd0 /src/node_native_module.cc
parent6c257cdf271384555d0ced77104a1d6b0480e246 (diff)
src: allocate Buffer memory using ArrayBuffer allocator
Always use the right allocator for memory that is turned into an `ArrayBuffer` at a later point. This enables embedders to use their own `ArrayBuffer::Allocator`s, and is inspired by Electron’s electron/node@f61bae3440e. It should render their downstream patch unnecessary. Refs: https://github.com/electron/node/commit/f61bae3440e1bfcc83bba6ff0785adfb89b4045e PR-URL: https://github.com/nodejs/node/pull/26207 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'src/node_native_module.cc')
-rw-r--r--src/node_native_module.cc10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/node_native_module.cc b/src/node_native_module.cc
index 2d3769ebf5c..df7e1749e52 100644
--- a/src/node_native_module.cc
+++ b/src/node_native_module.cc
@@ -11,7 +11,6 @@ namespace native_module {
using v8::Array;
using v8::ArrayBuffer;
-using v8::ArrayBufferCreationMode;
using v8::Context;
using v8::DEFAULT;
using v8::EscapableHandleScope;
@@ -153,13 +152,8 @@ MaybeLocal<Uint8Array> NativeModuleLoader::GetCodeCache(Isolate* isolate,
cached_data = it->second.get();
- MallocedBuffer<uint8_t> copied(cached_data->length);
- memcpy(copied.data, cached_data->data, cached_data->length);
- Local<ArrayBuffer> buf =
- ArrayBuffer::New(isolate,
- copied.release(),
- cached_data->length,
- ArrayBufferCreationMode::kInternalized);
+ Local<ArrayBuffer> buf = ArrayBuffer::New(isolate, cached_data->length);
+ memcpy(buf->GetContents().Data(), cached_data->data, cached_data->length);
return scope.Escape(Uint8Array::New(buf, 0, cached_data->length));
}