X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fbase.cpp;h=8e81f7b73d09b83a16ef730339edf989c94850d6;hb=2553e4fff7a5a168ef796dcecb73c7365651c897;hp=bf42327544dd925b6b951ed03fe226ec2d998478;hpb=9facfd70b5a8ca4dca16fc93f6fcfe1c2bf6ce0f;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/base.cpp b/src/base.cpp index bf4232754..8e81f7b73 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -43,7 +43,6 @@ CullResult::CullResult() // This trick detects heap allocations of refcountbase objects static void* last_heap = NULL; -static const unsigned int top_bit = 1 << (8*sizeof(unsigned int) - 1); void* refcountbase::operator new(size_t size) { @@ -58,21 +57,26 @@ void refcountbase::operator delete(void* obj) ::operator delete(obj); } -refcountbase::refcountbase() +refcountbase::refcountbase() : refcount(0) { - if (this == last_heap) - refcount = 0; - else - refcount = top_bit; + if (this != last_heap) + throw CoreException("Reference allocate on the stack!"); } refcountbase::~refcountbase() { - if ((refcount & ~top_bit) && ServerInstance && ServerInstance->Logs) - ServerInstance->Logs->Log("CULLLIST", DEBUG, "refcountbase::~ @%p with refcount %x", + if (refcount && ServerInstance && ServerInstance->Logs) + ServerInstance->Logs->Log("CULLLIST", DEBUG, "refcountbase::~ @%p with refcount %d", (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) { } @@ -297,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); -}