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 98a0770

Browse filesBrowse files
fhinkelMylesBorins
authored andcommitted
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: #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>
1 parent 2eec944 commit 98a0770
Copy full SHA for 98a0770

File tree

Expand file treeCollapse file tree

1 file changed

+4
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-5
lines changed
Open diff view settings
Collapse file

‎src/node.cc‎

Copy file name to clipboardExpand all lines: src/node.cc
+4-5Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ node::DebugOptions debug_options;
263263
static struct {
264264
#if NODE_USE_V8_PLATFORM
265265
void Initialize(int thread_pool_size) {
266-
tracing_agent_ =
267-
trace_enabled ? new tracing::Agent() : nullptr;
266+
tracing_agent_.reset(
267+
trace_enabled ? new tracing::Agent() : nullptr);
268268
platform_ = new NodePlatform(thread_pool_size,
269269
trace_enabled ? tracing_agent_->GetTracingController() : nullptr);
270270
V8::InitializePlatform(platform_);
@@ -276,8 +276,7 @@ static struct {
276276
platform_->Shutdown();
277277
delete platform_;
278278
platform_ = nullptr;
279-
delete tracing_agent_;
280-
tracing_agent_ = nullptr;
279+
tracing_agent_.reset(nullptr);
281280
}
282281

283282
void DrainVMTasks(Isolate* isolate) {
@@ -314,7 +313,7 @@ static struct {
314313
return platform_;
315314
}
316315

317-
tracing::Agent* tracing_agent_;
316+
std::unique_ptr<tracing::Agent> tracing_agent_;
318317
NodePlatform* platform_;
319318
#else // !NODE_USE_V8_PLATFORM
320319
void Initialize(int thread_pool_size) {}

0 commit comments

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