summaryrefslogtreecommitdiff
path: root/src/inspector_io.cc
diff options
context:
space:
mode:
authorFranziska Hinkelmann <franziska.hinkelmann@gmail.com>2017-11-12 21:01:01 +0100
committerFranziska Hinkelmann <franziska.hinkelmann@gmail.com>2017-11-17 10:37:04 +0100
commitf96abea88e8b9898f477e131aa315d3cccbeb349 (patch)
treeb28dbcaa90a77391d3211434b5a7fecc7932b24f /src/inspector_io.cc
parentc661dad0868ed31deaf3ba93027eceabe09fd53b (diff)
downloadandroid-node-v8-f96abea88e8b9898f477e131aa315d3cccbeb349.tar.gz
android-node-v8-f96abea88e8b9898f477e131aa315d3cccbeb349.tar.bz2
android-node-v8-f96abea88e8b9898f477e131aa315d3cccbeb349.zip
src: use smart pointer instead of new and delete
Use an std::unique_ptr for variables that are deleted right after creation. Since the destructor of InspectorTimer is private but needed by the unique_ptr, define deleter_type as friend. PR-URL: https://github.com/nodejs/node/pull/17020 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Diffstat (limited to 'src/inspector_io.cc')
-rw-r--r--src/inspector_io.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/inspector_io.cc b/src/inspector_io.cc
index 73f0419ead..a870c0a263 100644
--- a/src/inspector_io.cc
+++ b/src/inspector_io.cc
@@ -114,9 +114,9 @@ int CloseAsyncAndLoop(uv_async_t* async) {
// Delete main_thread_req_ on async handle close
void ReleasePairOnAsyncClose(uv_handle_t* async) {
- AsyncAndAgent* pair = node::ContainerOf(&AsyncAndAgent::first,
- reinterpret_cast<uv_async_t*>(async));
- delete pair;
+ std::unique_ptr<AsyncAndAgent> pair(node::ContainerOf(&AsyncAndAgent::first,
+ reinterpret_cast<uv_async_t*>(async)));
+ // Unique_ptr goes out of scope here and pointer is deleted.
}
} // namespace