From 24c169c39fb8b2efb0138cbd9220ae75ecb839bd Mon Sep 17 00:00:00 2001 From: brain Date: Mon, 11 Apr 2005 21:18:02 +0000 Subject: More fixes :/ git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1054 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/inspircd.cpp | 80 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 83b72cba5..6ec5631a7 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -3396,6 +3396,48 @@ char* ModuleError() return MODERR; } +void erase_factory(int j) +{ + int v = 0; + for (std::vector::iterator t = factory.begin(); t != factory.end(); t++) + { + if (v == j) + { + factory.erase(t); + factory.push_back(NULL); + return; + } + v++; + } +} + +void erase_module(int j) +{ + int v = 0; + for (std::vector::iterator m = modules.begin(); m!= modules.end(); m++) + { + if (v == j) + { + delete *m; + modules.erase(m); + modules.push_back(NULL); + break; + } + v++; + } + int v2 = 0; + for (std::vector::iterator v = module_names.begin(); v != module_names.end(); v++) + { + if (v2 == j) + { + module_names.erase(v); + break; + } + v2++; + } + +} + bool UnloadModule(const char* filename) { for (int j = 0; j != module_names.size(); j++) @@ -3410,43 +3452,9 @@ bool UnloadModule(const char* filename) } // found the module log(DEBUG,"Deleting module..."); - delete modules[j]; - modules[j] = NULL; - log(DEBUG,"Deleting module factory pointer..."); - delete factory[j]->factory; + erase_module(j); log(DEBUG,"Erasing module entry..."); - factory[j] = NULL; - // here we should locate ALL resources claimed by this module... and release them - // for example commands - log(DEBUG,"Erasing module vector..."); - for (std::vector::iterator t = factory.begin(); t != factory.end(); t++) - { - if (*t == NULL) - { - factory.erase(t); - factory.push_back(NULL); - break; - } - } - log(DEBUG,"Erasing module name vector..."); - for (std::vector::iterator v = module_names.begin(); v != module_names.end(); v++) - { - if (*v == std::string(filename)) - { - module_names.erase(v); - break; - } - } - log(DEBUG,"Erasing module pointer..."); - for (std::vector::iterator m = modules.begin(); m!= modules.end(); m++) - { - if (*m == NULL) - { - modules.erase(m); - modules.push_back(NULL); - break; - } - } + erase_factory(j); log(DEBUG,"Removing dependent commands..."); removecommands(filename); log(DEFAULT,"Module %s unloaded",filename); -- cgit v1.2.3