X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fbase.cpp;h=caa45c3b045e81de184eae45b7660ab7737088aa;hb=235864add961270140c956647d783fa79b5f7120;hp=389f3915a06fb96bfb8becc30f107d4664030c2b;hpb=aa7cc18468f4b16bf79cd1788cad0cbf0d926817;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/base.cpp b/src/base.cpp index 389f3915a..caa45c3b0 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * InspIRCd: (C) 2002-2010 InspIRCd Development Team * See: http://wiki.inspircd.org/Credits * * This program is free but copyrighted software; see @@ -41,8 +41,26 @@ CullResult::CullResult() { } +// This trick detects heap allocations of refcountbase objects +static void* last_heap = NULL; + +void* refcountbase::operator new(size_t size) +{ + last_heap = ::operator new(size); + return last_heap; +} + +void refcountbase::operator delete(void* obj) +{ + if (last_heap == obj) + last_heap = NULL; + ::operator delete(obj); +} + refcountbase::refcountbase() : refcount(0) { + if (this != last_heap) + throw CoreException("Reference allocate on the stack!"); } refcountbase::~refcountbase() @@ -52,7 +70,18 @@ refcountbase::~refcountbase() (void*)this, refcount); } -ExtensionItem::ExtensionItem(const std::string& Key, Module* mod) : key(Key), owner(mod) +usecountbase::~usecountbase() +{ + if (usecount && ServerInstance && ServerInstance->Logs) + ServerInstance->Logs->Log("CULLLIST", DEBUG, "usecountbase::~ @%p with refcount %d", + (void*)this, usecount); +} + +ServiceProvider::~ServiceProvider() +{ +} + +ExtensionItem::ExtensionItem(const std::string& Key, Module* mod) : ServiceProvider(mod, Key, SERVICE_METADATA) { } @@ -97,7 +126,7 @@ void* ExtensionItem::unset_raw(Extensible* container) void ExtensionManager::Register(ExtensionItem* item) { - types.insert(std::make_pair(item->key, item)); + types.insert(std::make_pair(item->name, item)); } void ExtensionManager::BeginUnregister(Module* module, std::vector >& list) @@ -107,7 +136,7 @@ void ExtensionManager::BeginUnregister(Module* module, std::vector >::iterator me = i++; ExtensionItem* item = me->second; - if (item->owner == module) + if (item->creator == module) { list.push_back(item); types.erase(me); @@ -270,3 +299,9 @@ void StringExtItem::free(void* item) { delete static_cast(item); } + +ModuleException::ModuleException(const std::string &message, Module* who) + : CoreException(message, who ? who->ModuleSourceFile : "A Module") +{ +} +