@@ -59,7 +59,7 @@ class HTTPRPCTimerInterface : public RPCTimerInterface
5959/* Pre-base64-encoded authentication token */
6060static std::string strRPCUserColonPass;
6161/* Stored RPC timer interface (for unregistration) */
62- static HTTPRPCTimerInterface* httpRPCTimerInterface = 0 ;
62+ static std::unique_ptr< HTTPRPCTimerInterface> httpRPCTimerInterface;
6363
6464static void JSONErrorReply (HTTPRequest* req, const UniValue& objError, const UniValue& id)
6565{
@@ -233,8 +233,8 @@ bool StartHTTPRPC()
233233 RegisterHTTPHandler (" /wallet/" , false , HTTPReq_JSONRPC);
234234#endif
235235 assert (EventBase ());
236- httpRPCTimerInterface = new HTTPRPCTimerInterface (EventBase ());
237- RPCSetTimerInterface (httpRPCTimerInterface);
236+ httpRPCTimerInterface = std::unique_ptr<HTTPRPCTimerInterface>( new HTTPRPCTimerInterface (EventBase () ));
237+ RPCSetTimerInterface (httpRPCTimerInterface. get () );
238238 return true ;
239239}
240240
@@ -248,8 +248,7 @@ void StopHTTPRPC()
248248 LogPrint (BCLog::RPC, " Stopping HTTP RPC server\n " );
249249 UnregisterHTTPHandler (" /" , true );
250250 if (httpRPCTimerInterface) {
251- RPCUnsetTimerInterface (httpRPCTimerInterface);
252- delete httpRPCTimerInterface;
253- httpRPCTimerInterface = 0 ;
251+ RPCUnsetTimerInterface (httpRPCTimerInterface.get ());
252+ httpRPCTimerInterface.reset ();
254253 }
255254}
0 commit comments