aboutsummaryrefslogtreecommitdiff
path: root/src/zmq/zmqabstractnotifier.h
diff options
context:
space:
mode:
authorDaniel Kraft <d@domob.eu>2018-07-17 12:36:22 +0200
committerDaniel Kraft <d@domob.eu>2020-09-07 10:55:55 +0200
commit7f2ad1b9acef4ccc1b3e1a9f551416235d95cbfd (patch)
tree196d1e6dcae168a705e4af1739473485bd6794a3 /src/zmq/zmqabstractnotifier.h
parentb93b9d54569145bfcec6cee10968284fe05fe254 (diff)
downloadbitcoin-7f2ad1b9acef4ccc1b3e1a9f551416235d95cbfd.tar.xz
Use std::unique_ptr for CZMQNotifierFactory.
Instead of returning a raw pointer from CZMQNotifierFactory and implicitly requiring the caller to know that it has to take ownership, return a std::unique_ptr to make this explicit. This also changes the typedef for CZMQNotifierFactory to use the new C++11 using syntax, which makes it (a little) less cryptic.
Diffstat (limited to 'src/zmq/zmqabstractnotifier.h')
-rw-r--r--src/zmq/zmqabstractnotifier.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/zmq/zmqabstractnotifier.h b/src/zmq/zmqabstractnotifier.h
index 887dde7b27..8377a26d3a 100644
--- a/src/zmq/zmqabstractnotifier.h
+++ b/src/zmq/zmqabstractnotifier.h
@@ -7,10 +7,14 @@
#include <zmq/zmqconfig.h>
+#include <util/memory.h>
+
+#include <memory>
+
class CBlockIndex;
class CZMQAbstractNotifier;
-typedef CZMQAbstractNotifier* (*CZMQNotifierFactory)();
+using CZMQNotifierFactory = std::unique_ptr<CZMQAbstractNotifier> (*)();
class CZMQAbstractNotifier
{
@@ -21,9 +25,9 @@ public:
virtual ~CZMQAbstractNotifier();
template <typename T>
- static CZMQAbstractNotifier* Create()
+ static std::unique_ptr<CZMQAbstractNotifier> Create()
{
- return new T();
+ return MakeUnique<T>();
}
std::string GetType() const { return type; }