summaryrefslogtreecommitdiff
path: root/src/node_file.cc
diff options
context:
space:
mode:
authorGireesh Punathil <gpunathi@in.ibm.com>2018-09-27 10:18:58 -0400
committerDaniel Bevenius <daniel.bevenius@gmail.com>2018-10-01 06:18:46 +0200
commitd407291dcc031e899fc1c52265b33707a1258b59 (patch)
treed2711de562358dd60478df3f44c347c493e2aef5 /src/node_file.cc
parentaba7677e826065fc1f1025ee2db5faee035fd515 (diff)
downloadandroid-node-v8-d407291dcc031e899fc1c52265b33707a1258b59.tar.gz
android-node-v8-d407291dcc031e899fc1c52265b33707a1258b59.tar.bz2
android-node-v8-d407291dcc031e899fc1c52265b33707a1258b59.zip
src: unique_ptrs in few lambdas
Few lambdas in src/node_file.cc uses conventional pointers, turn those into unique_ptr semantics PR-URL: https://github.com/nodejs/node/pull/23124 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'src/node_file.cc')
-rw-r--r--src/node_file.cc9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/node_file.cc b/src/node_file.cc
index 20cb4771bd..6a71ef1124 100644
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@ -163,7 +163,7 @@ inline void FileHandle::Close() {
// Do not unref this
env()->SetImmediate([](Environment* env, void* data) {
char msg[70];
- err_detail* detail = static_cast<err_detail*>(data);
+ std::unique_ptr<err_detail> detail(static_cast<err_detail*>(data));
snprintf(msg, arraysize(msg),
"Closing file descriptor %d on garbage collection failed",
detail->fd);
@@ -173,7 +173,6 @@ inline void FileHandle::Close() {
// down the process is the only reasonable thing we can do here.
HandleScope handle_scope(env->isolate());
env->ThrowUVException(detail->ret, "close", msg);
- delete detail;
}, detail);
return;
}
@@ -182,11 +181,10 @@ inline void FileHandle::Close() {
// to notify that the file descriptor was gc'd. We want to be noisy about
// this because not explicitly closing the FileHandle is a bug.
env()->SetUnrefImmediate([](Environment* env, void* data) {
- err_detail* detail = static_cast<err_detail*>(data);
+ std::unique_ptr<err_detail> detail(static_cast<err_detail*>(data));
ProcessEmitWarning(env,
"Closing file descriptor %d on garbage collection",
detail->fd);
- delete detail;
}, detail);
}
@@ -234,7 +232,7 @@ inline MaybeLocal<Promise> FileHandle::ClosePromise() {
closing_ = true;
CloseReq* req = new CloseReq(env(), promise, object());
auto AfterClose = uv_fs_callback_t{[](uv_fs_t* req) {
- CloseReq* close = CloseReq::from_req(req);
+ std::unique_ptr<CloseReq> close(CloseReq::from_req(req));
CHECK_NOT_NULL(close);
close->file_handle()->AfterClose();
Isolate* isolate = close->env()->isolate();
@@ -243,7 +241,6 @@ inline MaybeLocal<Promise> FileHandle::ClosePromise() {
} else {
close->Resolve();
}
- delete close;
}};
int ret = req->Dispatch(uv_fs_close, fd_, AfterClose);
if (ret < 0) {