diff options
author | Daniel Bevenius <daniel.bevenius@gmail.com> | 2017-11-28 08:45:35 +0100 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2017-12-01 07:56:39 +0100 |
commit | 6aee5fbf993b4e8a2b62d45259f324bc8513f2aa (patch) | |
tree | ea3bb37b8092b78e02986e32b8b5ddbb8547c94a /test/cctest | |
parent | 12c8b4d15471cb6211b39c3a2ca5b10fa4b9f12b (diff) | |
download | android-node-v8-6aee5fbf993b4e8a2b62d45259f324bc8513f2aa.tar.gz android-node-v8-6aee5fbf993b4e8a2b62d45259f324bc8513f2aa.tar.bz2 android-node-v8-6aee5fbf993b4e8a2b62d45259f324bc8513f2aa.zip |
test: use v8 Default Allocator in cctest fixture
This commit updates the node_test_fixture to use
v8::ArrayBuffer::Allocator::NewDefaultAllocator() and removes the custom
allocator.
PR-URL: https://github.com/nodejs/node/pull/17366
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'test/cctest')
-rw-r--r-- | test/cctest/node_test_fixture.h | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/test/cctest/node_test_fixture.h b/test/cctest/node_test_fixture.h index 890fe90499..bbc46986eb 100644 --- a/test/cctest/node_test_fixture.h +++ b/test/cctest/node_test_fixture.h @@ -9,21 +9,6 @@ #include "v8.h" #include "libplatform/libplatform.h" -class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { - public: - virtual void* Allocate(size_t length) { - return AllocateUninitialized(length); - } - - virtual void* AllocateUninitialized(size_t length) { - return calloc(length, 1); - } - - virtual void Free(void* data, size_t) { - free(data); - } -}; - struct Argv { public: Argv() : Argv({"node", "-p", "process.version"}) {} @@ -77,7 +62,6 @@ class NodeTestFixture : public ::testing::Test { protected: v8::Isolate::CreateParams params_; - ArrayBufferAllocator allocator_; v8::Isolate* isolate_; ~NodeTestFixture() { @@ -89,7 +73,7 @@ class NodeTestFixture : public ::testing::Test { platform_ = new node::NodePlatform(8, nullptr); v8::V8::InitializePlatform(platform_); v8::V8::Initialize(); - params_.array_buffer_allocator = &allocator_; + params_.array_buffer_allocator = allocator_.get(); isolate_ = v8::Isolate::New(params_); } @@ -107,6 +91,8 @@ class NodeTestFixture : public ::testing::Test { private: node::NodePlatform* platform_ = nullptr; + std::unique_ptr<v8::ArrayBuffer::Allocator> allocator_{ + v8::ArrayBuffer::Allocator::NewDefaultAllocator()}; }; #endif // TEST_CCTEST_NODE_TEST_FIXTURE_H_ |