diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-04-11 21:18:02 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-04-11 21:18:02 +0000 |
commit | 24c169c39fb8b2efb0138cbd9220ae75ecb839bd (patch) | |
tree | 6b2bb6d4fcfd29df121468dfb22c3d45ff3ed9de | |
parent | 03541204fcd4a47916e97836d60944b1abb632c2 (diff) |
More fixes :/
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1054 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | src/inspircd.cpp | 80 |
1 files 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<ircd_module*>::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<Module*>::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<std::string>::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<ircd_module*>::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<std::string>::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<Module*>::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); |