Skip to content

Commit

Permalink
src: make req_wrap a unique_ptr in AfterConnect
Browse files Browse the repository at this point in the history
PR-URL: #23115
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
danbev authored and targos committed Oct 3, 2018
1 parent ce7fad5 commit 20a4f14
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/connection_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ void ConnectionWrap<WrapType, UVType>::OnConnection(uv_stream_t* handle,
template <typename WrapType, typename UVType>
void ConnectionWrap<WrapType, UVType>::AfterConnect(uv_connect_t* req,
int status) {
ConnectWrap* req_wrap = static_cast<ConnectWrap*>(req->data);
std::unique_ptr<ConnectWrap> req_wrap
(static_cast<ConnectWrap*>(req->data));
CHECK_NOT_NULL(req_wrap);
WrapType* wrap = static_cast<WrapType*>(req->handle->data);
CHECK_EQ(req_wrap->env(), wrap->env());
Expand Down Expand Up @@ -108,8 +109,6 @@ void ConnectionWrap<WrapType, UVType>::AfterConnect(uv_connect_t* req,
};

req_wrap->MakeCallback(env->oncomplete_string(), arraysize(argv), argv);

delete req_wrap;
}

template ConnectionWrap<PipeWrap, uv_pipe_t>::ConnectionWrap(
Expand Down

0 comments on commit 20a4f14

Please sign in to comment.