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 77205b7

Browse filesBrowse 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 <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 ecb78e6 commit 77205b7
Copy full SHA for 77205b7

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"}) {}
@@ -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_ = new node::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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.