mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
src: use unique pointer for tracing_agent
Use std::unique_ptr instead of raw pointers for the tracing_agent_ in node.cc. This makes ownership clearer and we don't risk a memory leak. PR-URL: https://github.com/nodejs/node/pull/17012 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
This commit is contained in:
1 parent
2eec94489d
commit
98a07709f4
1 file changed
+4
-5
+4
-5
@@ -263,8 +263,8 @@ node::DebugOptions debug_options;
|
||||
static struct {
|
||||
#if NODE_USE_V8_PLATFORM
|
||||
void Initialize(int thread_pool_size) {
|
||||
tracing_agent_ =
|
||||
trace_enabled ? new tracing::Agent() : nullptr;
|
||||
tracing_agent_.reset(
|
||||
trace_enabled ? new tracing::Agent() : nullptr);
|
||||
platform_ = new NodePlatform(thread_pool_size,
|
||||
trace_enabled ? tracing_agent_->GetTracingController() : nullptr);
|
||||
V8::InitializePlatform(platform_);
|
||||
@@ -276,8 +276,7 @@ static struct {
|
||||
platform_->Shutdown();
|
||||
delete platform_;
|
||||
platform_ = nullptr;
|
||||
delete tracing_agent_;
|
||||
tracing_agent_ = nullptr;
|
||||
tracing_agent_.reset(nullptr);
|
||||
}
|
||||
|
||||
void DrainVMTasks(Isolate* isolate) {
|
||||
@@ -314,7 +313,7 @@ static struct {
|
||||
return platform_;
|
||||
}
|
||||
|
||||
tracing::Agent* tracing_agent_;
|
||||
std::unique_ptr<tracing::Agent> tracing_agent_;
|
||||
NodePlatform* platform_;
|
||||
#else // !NODE_USE_V8_PLATFORM
|
||||
void Initialize(int thread_pool_size) {}
|
||||
|
||||
Reference in new issue
Block a user