@@ -62,7 +62,7 @@ class HTTPRPCTimerInterface : public RPCTimerInterface
62
62
/* Pre-base64-encoded authentication token */
63
63
static std::string strRPCUserColonPass;
64
64
/* Stored RPC timer interface (for unregistration) */
65
- static HTTPRPCTimerInterface* httpRPCTimerInterface = nullptr ;
65
+ static std::unique_ptr< HTTPRPCTimerInterface> httpRPCTimerInterface;
66
66
67
67
static void JSONErrorReply (HTTPRequest* req, const UniValue& objError, const UniValue& id)
68
68
{
@@ -238,8 +238,8 @@ bool StartHTTPRPC()
238
238
RegisterHTTPHandler (" /wallet/" , false , HTTPReq_JSONRPC);
239
239
#endif
240
240
assert (EventBase ());
241
- httpRPCTimerInterface = new HTTPRPCTimerInterface (EventBase ());
242
- RPCSetTimerInterface (httpRPCTimerInterface);
241
+ httpRPCTimerInterface = std::unique_ptr<HTTPRPCTimerInterface>( new HTTPRPCTimerInterface (EventBase () ));
242
+ RPCSetTimerInterface (httpRPCTimerInterface. get () );
243
243
return true ;
244
244
}
245
245
@@ -253,8 +253,7 @@ void StopHTTPRPC()
253
253
LogPrint (BCLog::RPC, " Stopping HTTP RPC server\n " );
254
254
UnregisterHTTPHandler (" /" , true );
255
255
if (httpRPCTimerInterface) {
256
- RPCUnsetTimerInterface (httpRPCTimerInterface);
257
- delete httpRPCTimerInterface;
258
- httpRPCTimerInterface = nullptr ;
256
+ RPCUnsetTimerInterface (httpRPCTimerInterface.get ());
257
+ httpRPCTimerInterface.reset ();
259
258
}
260
259
}
0 commit comments