1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-19 04:29:09 +00:00

Codechange: Use std::unique_ptr for link graph schedule handlers.

This removes manual memory management.
This commit is contained in:
2024-10-09 00:48:15 +01:00
parent 4a6ac52d8c
commit 4e57757c8f
2 changed files with 7 additions and 10 deletions

View File

@@ -143,12 +143,12 @@ void LinkGraphSchedule::ShiftDates(TimerGameEconomy::Date interval)
*/
LinkGraphSchedule::LinkGraphSchedule()
{
this->handlers[0] = new InitHandler;
this->handlers[1] = new DemandHandler;
this->handlers[2] = new MCFHandler<MCF1stPass>;
this->handlers[3] = new FlowMapper(false);
this->handlers[4] = new MCFHandler<MCF2ndPass>;
this->handlers[5] = new FlowMapper(true);
this->handlers[0] = std::make_unique<InitHandler>();
this->handlers[1] = std::make_unique<DemandHandler>();
this->handlers[2] = std::make_unique<MCFHandler<MCF1stPass>>();
this->handlers[3] = std::make_unique<FlowMapper>(false);
this->handlers[4] = std::make_unique<MCFHandler<MCF2ndPass>>();
this->handlers[5] = std::make_unique<FlowMapper>(true);
}
/**
@@ -157,9 +157,6 @@ LinkGraphSchedule::LinkGraphSchedule()
LinkGraphSchedule::~LinkGraphSchedule()
{
this->Clear();
for (const auto &handler : this->handlers) {
delete handler;
}
}
/**

View File

@@ -42,7 +42,7 @@ private:
friend SaveLoadTable GetLinkGraphScheduleDesc();
protected:
ComponentHandler *handlers[6]; ///< Handlers to be run for each job.
std::array<std::unique_ptr<ComponentHandler>, 6> handlers{}; ///< Handlers to be run for each job.
GraphList schedule; ///< Queue for new jobs.
JobList running; ///< Currently running jobs.