Commit 2b4e9cc6 authored by Max Kellermann's avatar Max Kellermann

db/update/Service: wrap UpdateWalk in std::unique_ptr<>

parent afdaaba0
...@@ -56,8 +56,6 @@ UpdateService::~UpdateService() ...@@ -56,8 +56,6 @@ UpdateService::~UpdateService()
if (update_thread.IsDefined()) if (update_thread.IsDefined())
update_thread.Join(); update_thread.Join();
delete walk;
} }
void void
...@@ -151,7 +149,8 @@ UpdateService::StartThread(UpdateQueueItem &&i) ...@@ -151,7 +149,8 @@ UpdateService::StartThread(UpdateQueueItem &&i)
modified = false; modified = false;
next = std::move(i); next = std::move(i);
walk = new UpdateWalk(config, GetEventLoop(), listener, *next.storage); walk = std::make_unique<UpdateWalk>(config, GetEventLoop(), listener,
*next.storage);
update_thread.Start(); update_thread.Start();
...@@ -248,8 +247,7 @@ UpdateService::RunDeferred() noexcept ...@@ -248,8 +247,7 @@ UpdateService::RunDeferred() noexcept
if (update_thread.IsDefined()) if (update_thread.IsDefined())
update_thread.Join(); update_thread.Join();
delete walk; walk.reset();
walk = nullptr;
next.Clear(); next.Clear();
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include "thread/Thread.hxx" #include "thread/Thread.hxx"
#include "util/Compiler.h" #include "util/Compiler.h"
#include <memory>
class SimpleDatabase; class SimpleDatabase;
class DatabaseListener; class DatabaseListener;
class UpdateWalk; class UpdateWalk;
...@@ -56,7 +58,7 @@ class UpdateService final { ...@@ -56,7 +58,7 @@ class UpdateService final {
UpdateQueueItem next; UpdateQueueItem next;
UpdateWalk *walk = nullptr; std::unique_ptr<UpdateWalk> walk;
public: public:
UpdateService(const ConfigData &_config, UpdateService(const ConfigData &_config,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment