]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/base.cpp
Fall back to copying bind IP if getsockname() fails, as it apparently can on Windows
[user/henk/code/inspircd.git] / src / base.cpp
index 389f3915a06fb96bfb8becc30f107d4664030c2b..caa45c3b045e81de184eae45b7660ab7737088aa 100644 (file)
@@ -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<reference<ExtensionItem> >& list)
@@ -107,7 +136,7 @@ void ExtensionManager::BeginUnregister(Module* module, std::vector<reference<Ext
        {
                std::map<std::string, reference<ExtensionItem> >::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<std::string*>(item);
 }
+
+ModuleException::ModuleException(const std::string &message, Module* who)
+       : CoreException(message, who ? who->ModuleSourceFile : "A Module")
+{
+}
+