Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ca81d4b

Browse filesBrowse files
danbevMylesBorins
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 <anna@addaleax.net> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent 1e34a0e commit ca81d4b
Copy full SHA for ca81d4b

File tree

Expand file treeCollapse file tree

1 file changed

+3
-17
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-17
lines changed
Open diff view settings
Collapse file

‎test/cctest/node_test_fixture.h‎

Copy file name to clipboardExpand all lines: test/cctest/node_test_fixture.h
+3-17Lines 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-
class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
13-
public:
14-
virtual void* Allocate(size_t length) {
15-
return AllocateUninitialized(length);
16-
}
17-
18-
virtual void* AllocateUninitialized(size_t length) {
19-
return calloc(length, 1);
20-
}
21-
22-
virtual void Free(void* data, size_t) {
23-
free(data);
24-
}
25-
};
26-
2712
struct Argv {
2813
public:
2914
Argv() : Argv({"node", "-p", "process.version"}) {}
@@ -77,7 +62,6 @@ class NodeTestFixture : public ::testing::Test {
7762

7863
protected:
7964
v8::Isolate::CreateParams params_;
80-
ArrayBufferAllocator allocator_;
8165
v8::Isolate* isolate_;
8266

8367
~NodeTestFixture() {
@@ -89,7 +73,7 @@ class NodeTestFixture : public ::testing::Test {
8973
platform_ = new node::NodePlatform(8, nullptr);
9074
v8::V8::InitializePlatform(platform_);
9175
v8::V8::Initialize();
92-
params_.array_buffer_allocator = &allocator_;
76+
params_.array_buffer_allocator = allocator_.get();
9377
isolate_ = v8::Isolate::New(params_);
9478
}
9579

@@ -107,6 +91,8 @@ class NodeTestFixture : public ::testing::Test {
10791

10892
private:
10993
node::NodePlatform* platform_ = nullptr;
94+
std::unique_ptr<v8::ArrayBuffer::Allocator> allocator_{
95+
v8::ArrayBuffer::Allocator::NewDefaultAllocator()};
11096
};
11197

11298
#endif // TEST_CCTEST_NODE_TEST_FIXTURE_H_

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.