diff options
author | smatz <smatz@openttd.org> | 2008-05-08 23:26:17 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2008-05-08 23:26:17 +0000 |
commit | 5e51833ee5b6ca7db5c529c894bdac2bba49fbd8 (patch) | |
tree | 628a45bcfaef9713dcc41143b5bbb8485228b100 /src/driver.h | |
parent | 2ba05f898759269ba72b2ffd73aed7268e0ff56e (diff) | |
download | openttd-5e51833ee5b6ca7db5c529c894bdac2bba49fbd8.tar.xz |
(svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
Diffstat (limited to 'src/driver.h')
-rw-r--r-- | src/driver.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/driver.h b/src/driver.h index 6b8d857d3..7d1a3429c 100644 --- a/src/driver.h +++ b/src/driver.h @@ -43,7 +43,7 @@ private: static Drivers &GetDrivers() { - static Drivers &s_drivers = *new Drivers(); + static Drivers s_drivers; return s_drivers; } @@ -67,7 +67,23 @@ public: name(NULL) {} - virtual ~DriverFactoryBase() { if (this->name != NULL) GetDrivers().erase(this->name); free(this->name); } + /** Frees memory used for this->name + */ + virtual ~DriverFactoryBase() { + if (this->name == NULL) return; + GetDrivers().erase(this->name); + free(this->name); + } + + /** Shuts down all active drivers + */ + static void ShutdownDrivers() + { + for (Driver::Type dt = Driver::DT_BEGIN; dt < Driver::DT_END; dt++) { + Driver *driver = *GetActiveDriver(dt); + if (driver != NULL) driver->Stop(); + } + } static const Driver *SelectDriver(const char *name, Driver::Type type); static char *GetDriversInfo(char *p, const char *last); |