Skip to content

Commit a71f214

Browse files
danbevgibfahn
authored andcommitted
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: #17366 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 3c8bdd9 commit a71f214

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

‎test/cctest/node_test_fixture.h‎

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,6 @@
99
#include"v8.h"
1010
#include"libplatform/libplatform.h"
1111

12-
classArrayBufferAllocator : publicv8::ArrayBuffer::Allocator{
13-
public:
14-
virtualvoid* Allocate(size_t length){
15-
returnAllocateUninitialized(length);
16-
}
17-
18-
virtualvoid* AllocateUninitialized(size_t length){
19-
returncalloc(length, 1);
20-
}
21-
22-
virtualvoidFree(void* data, size_t){
23-
free(data);
24-
}
25-
};
26-
2712
structArgv{
2813
public:
2914
Argv() : Argv({"node", "-p", "process.version"}){}
@@ -75,7 +60,6 @@ class NodeTestFixture : public ::testing::Test{
7560

7661
protected:
7762
v8::Isolate::CreateParams params_;
78-
ArrayBufferAllocator allocator_;
7963
v8::Isolate* isolate_;
8064

8165
~NodeTestFixture(){
@@ -87,7 +71,7 @@ class NodeTestFixture : public ::testing::Test{
8771
platform_ = newnode::NodePlatform(8, &current_loop, nullptr);
8872
v8::V8::InitializePlatform(platform_);
8973
v8::V8::Initialize();
90-
params_.array_buffer_allocator = &allocator_;
74+
params_.array_buffer_allocator = allocator_.get();
9175
isolate_ = v8::Isolate::New(params_);
9276
}
9377

@@ -105,6 +89,8 @@ class NodeTestFixture : public ::testing::Test{
10589

10690
private:
10791
node::NodePlatform* platform_ = nullptr;
92+
std::unique_ptr<v8::ArrayBuffer::Allocator> allocator_{
93+
v8::ArrayBuffer::Allocator::NewDefaultAllocator()};
10894
};
10995

11096
#endif// TEST_CCTEST_NODE_TEST_FIXTURE_H_

0 commit comments

Comments
(0)