]> 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 c0bc40811a6ee0fd32a505471ee8e8f6cefe97a3..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)
 {
 }
@@ -276,12 +301,3 @@ ModuleException::ModuleException(const std::string &message, Module* who)
 {
 }
 
-ModuleRef::ModuleRef(Module* v) : value(v)
-{
-       if (value) inc(value);
-}
-
-ModuleRef::~ModuleRef()
-{
-       if (value) dec(value);
-}