summaryrefslogtreecommitdiff
path: root/src/cull_list.cpp
diff options
context:
space:
mode:
authorGravatar danieldg2009-10-02 03:15:46 +0000
committerGravatar danieldg2009-10-02 03:15:46 +0000
commit8456cf5ccd44911f4e56538fe0880dd7fc7cd96d (patch)
tree3e1f96b94cc86506a615d8b39131ff6ea7c1b64c /src/cull_list.cpp
parentMerge remote/local MODULES output (diff)
Fix valgrind issues and crashes on exit
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11794 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/cull_list.cpp')
-rw-r--r--src/cull_list.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/cull_list.cpp b/src/cull_list.cpp
index ff2bc64b5..f87095126 100644
--- a/src/cull_list.cpp
+++ b/src/cull_list.cpp
@@ -17,6 +17,8 @@
void CullList::Apply()
{
std::set<classbase*> gone;
+ std::vector<classbase*> queue;
+ queue.reserve(list.size() + 32);
for(unsigned int i=0; i < list.size(); i++)
{
classbase* c = list[i];
@@ -25,7 +27,7 @@ void CullList::Apply()
ServerInstance->Logs->Log("CULLLIST", DEBUG, "Deleting %s @%p", typeid(*c).name(),
(void*)c);
if (c->cull())
- delete c;
+ queue.push_back(c);
}
else
{
@@ -34,5 +36,15 @@ void CullList::Apply()
}
}
list.clear();
+ for(unsigned int i=0; i < queue.size(); i++)
+ {
+ classbase* c = queue[i];
+ delete c;
+ }
+ if (list.size())
+ {
+ ServerInstance->Logs->Log("CULLLIST",DEBUG, "WARNING: Objects added to cull list in a destructor");
+ Apply();
+ }
}