Instance: use std::unique_ptr<> to manage the NeighborGlue pointer

This commit is contained in:
Max Kellermann
2019-04-25 13:09:31 +02:00
parent 692c8025a2
commit f764925edc
4 changed files with 9 additions and 11 deletions

View File

@@ -448,15 +448,13 @@ MainOrThrow(int argc, char *argv[])
};
#ifdef ENABLE_NEIGHBOR_PLUGINS
instance->neighbors = new NeighborGlue();
instance->neighbors = std::make_unique<NeighborGlue>();
instance->neighbors->Init(raw_config,
instance->io_thread.GetEventLoop(),
*instance);
if (instance->neighbors->IsEmpty()) {
delete instance->neighbors;
instance->neighbors = nullptr;
}
if (instance->neighbors->IsEmpty())
instance->neighbors.reset();
#endif
const unsigned max_clients =
@@ -625,10 +623,6 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config)
delete instance->client_list;
#ifdef ENABLE_NEIGHBOR_PLUGINS
delete instance->neighbors;
#endif
return EXIT_SUCCESS;
}