From a71f214282927ab43d01a6637a0a014f10cbcf53 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 28 Nov 2017 08:45:35 +0100 Subject: [PATCH] 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(-) diff --git a/test/cctest/node_test_fixture.h b/test/cctest/node_test_fixture.h index 263f7b96f9daec..6ffaf9634973ad 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"}) {} @@ -75,7 +60,6 @@ class NodeTestFixture : public ::testing::Test { protected: v8::Isolate::CreateParams params_; - ArrayBufferAllocator allocator_; v8::Isolate* isolate_; ~NodeTestFixture() { @@ -87,7 +71,7 @@ class NodeTestFixture : public ::testing::Test { platform_ = new node::NodePlatform(8, ¤t_loop, nullptr); v8::V8::InitializePlatform(platform_); v8::V8::Initialize(); - params_.array_buffer_allocator = &allocator_; + params_.array_buffer_allocator = allocator_.get(); isolate_ = v8::Isolate::New(params_); } @@ -105,6 +89,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_