From aa78685c99dc1cd2fe28a05ba55eb719e12f4029 Mon Sep 17 00:00:00 2001 From: rubidium Date: Wed, 1 Aug 2007 23:49:06 +0000 Subject: (svn r10745) -Codechange: generalize the pool cleanup/initialize functions for stations (in such a manner that they can be used for other pools too). --- src/station.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/station.cpp') diff --git a/src/station.cpp b/src/station.cpp index 02f165b6f..0f7db16ff 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -64,7 +64,6 @@ Station::~Station() { DEBUG(station, cDebugCtorLevel, "I-%3d", index); - DeleteName(string_id); MarkDirty(); RebuildStationLists(); InvalidateWindowClasses(WC_STATION_LIST); @@ -77,21 +76,28 @@ Station::~Station() /* Subsidies need removal as well */ DeleteSubsidyWithStation(index); - free(speclist); xy = 0; for (CargoID c = 0; c < NUM_CARGO; c++) { goods[c].cargo.Truncate(0); } + + this->QuickFree(); } -void* Station::operator new(size_t size) +void Station::QuickFree() +{ + DeleteName(this->string_id); + free(this->speclist); +} + +void *Station::operator new(size_t size) { Station *st = AllocateRaw(); return st; } -void* Station::operator new(size_t size, int st_idx) +void *Station::operator new(size_t size, int st_idx) { if (!AddBlockIfNeeded(&_Station_pool, st_idx)) error("Stations: failed loading savegame: too many stations"); @@ -480,7 +486,6 @@ RoadStop::~RoadStop() xy = INVALID_TILE; } - /** Low-level function for allocating a RoadStop on the pool */ RoadStop *RoadStop::AllocateRaw() { -- cgit v1.2.3-54-g00ecf