From 6aee5fbf993b4e8a2b62d45259f324bc8513f2aa Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 28 Nov 2017 08:45:35 +0100 Subject: 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 Reviewed-By: Timothy Gu Reviewed-By: Colin Ihrig Reviewed-By: Ben Noordhuis --- test/cctest/node_test_fixture.h | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'test/cctest') 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 allocator_{ + v8::ArrayBuffer::Allocator::NewDefaultAllocator()}; }; #endif // TEST_CCTEST_NODE_TEST_FIXTURE_H_ -- cgit v1.2.3