refactor: Declare g_zmq_notification_interface as unique_ptr

Ensures better memory safety for this global. This came up during
discussion of the following commit, but is not strictly required for its
implementation.
This commit is contained in:
TheCharlatan
2023-04-17 10:42:49 +02:00
parent 883766fa45
commit 8ed4ff8e05
3 changed files with 8 additions and 9 deletions

View File

@@ -328,9 +328,8 @@ void Shutdown(NodeContext& node)
#if ENABLE_ZMQ
if (g_zmq_notification_interface) {
UnregisterValidationInterface(g_zmq_notification_interface);
delete g_zmq_notification_interface;
g_zmq_notification_interface = nullptr;
UnregisterValidationInterface(g_zmq_notification_interface.get());
g_zmq_notification_interface.reset();
}
#endif
@@ -1428,7 +1427,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
g_zmq_notification_interface = CZMQNotificationInterface::Create();
if (g_zmq_notification_interface) {
RegisterValidationInterface(g_zmq_notification_interface);
RegisterValidationInterface(g_zmq_notification_interface.get());
}
#endif