Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src, tools: replace raw ptr with smart ptr #28577

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/node_main_instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ NodeMainInstance::NodeMainInstance(Isolate* isolate,
SetIsolateUpForNode(isolate_, IsolateSettingCategories::kMisc);
}

NodeMainInstance* NodeMainInstance::Create(
std::unique_ptr<NodeMainInstance> NodeMainInstance::Create(
Isolate* isolate,
uv_loop_t* event_loop,
MultiIsolatePlatform* platform,
const std::vector<std::string>& args,
const std::vector<std::string>& exec_args) {
return new NodeMainInstance(isolate, event_loop, platform, args, exec_args);
return std::unique_ptr<NodeMainInstance>(
GauthamBanasandra marked this conversation as resolved.
Show resolved Hide resolved
new NodeMainInstance(isolate, event_loop, platform, args, exec_args));
}

NodeMainInstance::NodeMainInstance(
Expand Down Expand Up @@ -81,7 +82,6 @@ NodeMainInstance::NodeMainInstance(
void NodeMainInstance::Dispose() {
CHECK(!owns_isolate_);
platform_->DrainTasks(isolate_);
delete this;
}

NodeMainInstance::~NodeMainInstance() {
Expand Down
16 changes: 10 additions & 6 deletions src/node_main_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

#include <cstddef>
#include <memory>

#include "node.h"
#include "util.h"
#include "uv.h"
Expand All @@ -22,7 +24,7 @@ class NodeMainInstance {
// platform->RegisterIsolate(isolate, loop);
// isolate->Initialize(...);
// isolate->Enter();
// NodeMainInstance* main_instance =
// std::unique_ptr<NodeMainInstance> main_instance =
// NodeMainInstance::Create(isolate, loop, args, exec_args);
//
// When tearing it down:
Expand All @@ -33,11 +35,13 @@ class NodeMainInstance {
// platform->UnregisterIsolate(isolate);
//
// After calling Dispose() the main_instance is no longer accessible.
static NodeMainInstance* Create(v8::Isolate* isolate,
uv_loop_t* event_loop,
MultiIsolatePlatform* platform,
const std::vector<std::string>& args,
const std::vector<std::string>& exec_args);
static std::unique_ptr<NodeMainInstance> Create(
v8::Isolate* isolate,
uv_loop_t* event_loop,
MultiIsolatePlatform* platform,
const std::vector<std::string>& args,
const std::vector<std::string>& exec_args);

void Dispose();

// Create a main instance that owns the isolate
Expand Down
2 changes: 1 addition & 1 deletion tools/snapshot/snapshot_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ std::string SnapshotBuilder::Generate(
Isolate* isolate = Isolate::Allocate();
per_process::v8_platform.Platform()->RegisterIsolate(isolate,
uv_default_loop());
NodeMainInstance* main_instance = nullptr;
std::unique_ptr<NodeMainInstance> main_instance;
std::string result;

{
Expand Down