diff options
author | practicalswift <practicalswift@users.noreply.github.com> | 2017-08-09 15:08:58 +0200 |
---|---|---|
committer | practicalswift <practicalswift@users.noreply.github.com> | 2017-11-09 16:52:44 +0100 |
commit | 5a6f768896585c7077fca673d5f5410b1dd901d9 (patch) | |
tree | 9998486fa231051bb12d5a111a5e9f28e7a92666 /src/httprpc.cpp | |
parent | 860e912583b48fef7dc5b0399c40a7696ccfec55 (diff) |
Use unique_ptr for httpRPCTimerInterface (HTTPRPCTimerInterface)
Diffstat (limited to 'src/httprpc.cpp')
-rw-r--r-- | src/httprpc.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/httprpc.cpp b/src/httprpc.cpp index 93f0a18668..3b675b88e0 100644 --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -62,7 +62,7 @@ private: /* Pre-base64-encoded authentication token */ static std::string strRPCUserColonPass; /* Stored RPC timer interface (for unregistration) */ -static HTTPRPCTimerInterface* httpRPCTimerInterface = nullptr; +static std::unique_ptr<HTTPRPCTimerInterface> httpRPCTimerInterface; static void JSONErrorReply(HTTPRequest* req, const UniValue& objError, const UniValue& id) { @@ -238,8 +238,8 @@ bool StartHTTPRPC() RegisterHTTPHandler("/wallet/", false, HTTPReq_JSONRPC); #endif assert(EventBase()); - httpRPCTimerInterface = new HTTPRPCTimerInterface(EventBase()); - RPCSetTimerInterface(httpRPCTimerInterface); + httpRPCTimerInterface = std::unique_ptr<HTTPRPCTimerInterface>(new HTTPRPCTimerInterface(EventBase())); + RPCSetTimerInterface(httpRPCTimerInterface.get()); return true; } @@ -253,8 +253,7 @@ void StopHTTPRPC() LogPrint(BCLog::RPC, "Stopping HTTP RPC server\n"); UnregisterHTTPHandler("/", true); if (httpRPCTimerInterface) { - RPCUnsetTimerInterface(httpRPCTimerInterface); - delete httpRPCTimerInterface; - httpRPCTimerInterface = nullptr; + RPCUnsetTimerInterface(httpRPCTimerInterface.get()); + httpRPCTimerInterface.reset(); } } |