X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbase.cpp;h=59196fec1d6242fb1ca1a3f6ffad4cacd915517f;hb=a8878569083bfa4753e9e118adee0ed1da6a0325;hp=1b01da70710ab1948ea5c25dd834474c1e39eab4;hpb=e80a1296a096ff2c495b3cd2a3913d5e5f6ec450;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/base.cpp b/src/base.cpp index 1b01da707..59196fec1 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -11,33 +11,40 @@ * --------------------------------------------------- */ -/* $Core */ - #include "inspircd_config.h" #include "base.h" #include #include "inspircd.h" +#include classbase::classbase() { + if (ServerInstance && ServerInstance->Logs) + ServerInstance->Logs->Log("CULLLIST", DEBUG, "classbase::+%s @%p", + typeid(*this).name(), (void*)this); } -bool classbase::cull() +CullResult classbase::cull() { - return true; + if (ServerInstance && ServerInstance->Logs) + ServerInstance->Logs->Log("CULLLIST", DEBUG, "classbase::-%s @%p", + typeid(*this).name(), (void*)this); + return CullResult(); } classbase::~classbase() { + if (ServerInstance && ServerInstance->Logs) + ServerInstance->Logs->Log("CULLLIST", DEBUG, "classbase::~%s @%p", + typeid(*this).name(), (void*)this); } -refcountbase::refcountbase() : refcount(0) +CullResult::CullResult() { } -bool refcountbase::cull() +refcountbase::refcountbase() : refcount(0) { - return (refcount == 0); } refcountbase::~refcountbase() @@ -129,12 +136,32 @@ void Extensible::doUnhookExtensions(const std::vector& toRemove) } } -Extensible::~Extensible() +static struct DummyExtensionItem : LocalExtItem +{ + DummyExtensionItem() : LocalExtItem("", NULL) {} + void free(void*) {} +} dummy; + +Extensible::Extensible() +{ + extensions[&dummy] = NULL; +} + +CullResult Extensible::cull() { for(ExtensibleStore::iterator i = extensions.begin(); i != extensions.end(); ++i) { - i->first->free(i->second); + i->first->free(i->second); } + extensions.clear(); + return classbase::cull(); +} + +Extensible::~Extensible() +{ + if (!extensions.empty() && ServerInstance && ServerInstance->Logs) + ServerInstance->Logs->Log("CULLLIST", DEBUG, + "Extensible destructor called without cull @%p", (void*)this); } LocalExtItem::LocalExtItem(const std::string& Key, Module* mod) : ExtensionItem(Key, mod)