From 5e51833ee5b6ca7db5c529c894bdac2bba49fbd8 Mon Sep 17 00:00:00 2001 From: smatz Date: Thu, 8 May 2008 23:26:17 +0000 Subject: (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one --- src/driver.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/driver.h') 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); -- cgit v1.2.3-54-g00ecf