1
0
mirror of https://github.com/anope/anope.git synced 2026-06-27 03:16:37 +02:00

Store modules in a list and xlines in a vector, not deques. We need to be able to keep iterators valid.

This commit is contained in:
Adam
2010-06-20 21:33:01 -04:00
parent 0d2d7e9968
commit 17040c088a
7 changed files with 23 additions and 28 deletions
+1 -1
View File
@@ -158,7 +158,7 @@ enum MODType { CORE, PROTOCOL, THIRD, SUPPORTED, QATESTED, ENCRYPTION, DATABASE
struct Message;
extern CoreExport std::multimap<std::string, Message *> MessageMap;
class Module;
extern CoreExport std::deque<Module *> Modules;
extern CoreExport std::list<Module *> Modules;
/*************************************************************************/
/* Structure for information about a *Serv command. */
+5 -5
View File
@@ -69,7 +69,7 @@ class CoreExport XLineManager
protected:
/* List of XLines in this XLineManager */
std::deque<XLine *> XLines;
std::vector<XLine *> XLines;
public:
/** Constructor
*/
@@ -103,10 +103,10 @@ class CoreExport XLineManager
*/
const size_t GetCount() const;
/** Get the XLine list
* @return The list
/** Get the XLine vector
* @return The vector
*/
const std::deque<XLine *>& GetList() const;
const std::vector<XLine *>& GetList() const;
/** Add an entry to this XLineManager
* @param x The entry
@@ -125,7 +125,7 @@ class CoreExport XLineManager
*/
XLine *GetEntry(unsigned index) const;
/** Clear the XLine list
/** Clear the XLine vector
*/
void Clear();
+1 -1
View File
@@ -118,7 +118,7 @@ class CommandOSModList : public Command
notice_lang(Config.s_OperServ, u, OPER_MODULE_LIST_HEADER);
for (std::deque<Module *>::iterator it = Modules.begin(); it != Modules.end(); ++it)
for (std::list<Module *>::iterator it = Modules.begin(), it_end = Modules.end(); it != it_end; ++it)
{
Module *m = *it;
+3 -6
View File
@@ -116,13 +116,10 @@ Module::~Module()
}
}
for (std::deque<Module *>::iterator it = Modules.begin(), it_end = Modules.end(); it != it_end; ++it)
std::list<Module *>::iterator it = std::find(Modules.begin(), Modules.end(), this);
if (it != Modules.end())
{
if (*it == this)
{
Modules.erase(it);
break;
}
Modules.erase(it);
}
}
+3 -5
View File
@@ -87,7 +87,7 @@ static bool IsOneOfModuleTypeLoaded(MODType mt)
{
int pmods = 0;
for (std::deque<Module *>::iterator it = Modules.begin(), it_end = Modules.end(); it != it_end; ++it)
for (std::list<Module *>::const_iterator it = Modules.begin(), it_end = Modules.end(); it != it_end; ++it)
{
if ((*it)->type == mt)
++pmods;
@@ -471,14 +471,12 @@ void ModuleManager::ClearCallBacks(Module *m)
*/
void ModuleManager::UnloadAll(bool unload_proto)
{
for (std::deque<Module *>::iterator it = Modules.begin(), it_end = Modules.end(); it != it_end; )
for (std::list<Module *>::iterator it = Modules.begin(), it_end = Modules.end(); it != it_end; )
{
Module *m = *it++;
if (unload_proto || m->type != PROTOCOL)
DeleteModule(m);
if (Modules.empty())
break;
}
}
+2 -2
View File
@@ -14,7 +14,7 @@
#include "version.h"
std::multimap<std::string, Message *> MessageMap;
std::deque<Module *> Modules;
std::list<Module *> Modules;
char *mod_current_buffer = NULL;
@@ -93,7 +93,7 @@ void Module::InsertLanguage(int langNumber, int ac, const char **av)
*/
Module *FindModule(const std::string &name)
{
for (std::deque<Module *>::iterator it = Modules.begin(), it_end = Modules.end(); it != it_end; ++it)
for (std::list<Module *>::const_iterator it = Modules.begin(), it_end = Modules.end(); it != it_end; ++it)
{
Module *m = *it;
+8 -8
View File
@@ -272,10 +272,10 @@ const size_t XLineManager::GetCount() const
return XLines.size();
}
/** Get the XLine list
* @return The list
/** Get the XLine vector
* @return The vecotr
*/
const std::deque<XLine *>& XLineManager::GetList() const
const std::vector<XLine *>& XLineManager::GetList() const
{
return XLines;
}
@@ -294,7 +294,7 @@ void XLineManager::AddXLine(XLine *x)
*/
bool XLineManager::DelXLine(XLine *x)
{
std::deque<XLine *>::iterator it = std::find(XLines.begin(), XLines.end(), x);
std::vector<XLine *>::iterator it = std::find(XLines.begin(), XLines.end(), x);
if (it != XLines.end())
{
@@ -319,11 +319,11 @@ XLine *XLineManager::GetEntry(unsigned index) const
return XLines[index];
}
/** Clear the XLine list
/** Clear the XLine vector
*/
void XLineManager::Clear()
{
for (std::deque<XLine *>::iterator it = XLines.begin(), it_end = XLines.end(); it != it_end; ++it)
for (std::vector<XLine *>::iterator it = XLines.begin(), it_end = XLines.end(); it != it_end; ++it)
delete *it;
XLines.clear();
}
@@ -424,7 +424,7 @@ XLine *XLineManager::Check(User *u)
{
const time_t now = time(NULL);
for (std::deque<XLine *>::iterator it = XLines.begin(), it_end = XLines.end(); it != it_end; ++it)
for (std::vector<XLine *>::iterator it = XLines.begin(), it_end = XLines.end(); it != it_end; ++it)
{
XLine *x = *it;
@@ -727,7 +727,7 @@ bool SQLineManager::Check(Channel *c)
{
if (ircd->chansqline && SQLine)
{
for (std::deque<XLine *>::const_iterator it = SGLine->GetList().begin(), it_end = SGLine->GetList().end(); it != it_end; ++it)
for (std::vector<XLine *>::const_iterator it = SGLine->GetList().begin(), it_end = SGLine->GetList().end(); it != it_end; ++it)
{
XLine *x = *it;