]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/base.cpp
Match USERINPUT/USEROUTPUT identifiers
[user/henk/code/inspircd.git] / src / base.cpp
index 389f3915a06fb96bfb8becc30f107d4664030c2b..8e81f7b73d09b83a16ef730339edf989c94850d6 100644 (file)
@@ -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,6 +70,13 @@ refcountbase::~refcountbase()
                        (void*)this, refcount);
 }
 
+usecountbase::~usecountbase()
+{
+       if (usecount && ServerInstance && ServerInstance->Logs)
+               ServerInstance->Logs->Log("CULLLIST", DEBUG, "usecountbase::~ @%p with refcount %d",
+                       (void*)this, usecount);
+}
+
 ExtensionItem::ExtensionItem(const std::string& Key, Module* mod) : key(Key), owner(mod)
 {
 }
@@ -270,3 +295,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")
+{
+}
+