summaryrefslogtreecommitdiff
path: root/src/cull_list.cpp
diff options
context:
space:
mode:
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();
+ }
}