mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
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 <anna@addaleax.net> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
parent
12c8b4d154
commit
6aee5fbf99
@ -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<v8::ArrayBuffer::Allocator> allocator_{
|
||||
v8::ArrayBuffer::Allocator::NewDefaultAllocator()};
|
||||
};
|
||||
|
||||
#endif // TEST_CCTEST_NODE_TEST_FIXTURE_H_
|
||||
|
Loading…
Reference in New Issue
Block a user