]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
More fixes :/
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 11 Apr 2005 21:18:02 +0000 (21:18 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 11 Apr 2005 21:18:02 +0000 (21:18 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1054 e03df62e-2008-0410-955e-edbf42e46eb7

src/inspircd.cpp

index 83b72cba54459afcbc6b0cddc1a5377ad9e1bc7d..6ec5631a7add10d762c0ccc3aa8a20926fad93f0 100644 (file)
@@ -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);