From 8456cf5ccd44911f4e56538fe0880dd7fc7cd96d Mon Sep 17 00:00:00 2001 From: danieldg Date: Fri, 2 Oct 2009 03:15:46 +0000 Subject: Fix valgrind issues and crashes on exit git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11794 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/cull_list.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/cull_list.cpp') 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 gone; + std::vector 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(); + } } -- cgit v1.3.1-10-gc9f91