diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/base.cpp | 29 | ||||
-rw-r--r-- | src/inspircd.cpp | 4 | ||||
-rw-r--r-- | src/modules.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_showwhois.cpp | 2 |
4 files changed, 17 insertions, 22 deletions
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); -} diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 58480668b..b67815ed2 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -113,6 +113,8 @@ void InspIRCd::Cleanup() /* Must be deleted before modes as it decrements modelines */ if (FakeClient) FakeClient->cull(); + if (Res) + Res->cull(); DeleteZero(this->FakeClient); DeleteZero(this->Users); DeleteZero(this->Modes); @@ -523,7 +525,7 @@ InspIRCd::InspIRCd(int argc, char** argv) : this->Config->Apply(NULL, ""); Logs->OpenFileLogs(); - this->Res = new DNS; + this->Res = new DNS(); /* * Initialise SID/UID. diff --git a/src/modules.cpp b/src/modules.cpp index a1c53a1e8..b3aabf284 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -51,15 +51,13 @@ void Event::Send() // These declarations define the behavours of the base class Module (which does nothing at all) -Module::Module() : refcount(1) { } +Module::Module() { } CullResult Module::cull() { return classbase::cull(); } Module::~Module() { - if (refcount != 1) - ServerInstance->Logs->Log("MODULE", DEFAULT, "References remain to destructed module " + ModuleSourceFile); } ModResult Module::OnSendSnotice(char &snomask, std::string &type, const std::string &message) { return MOD_RES_PASSTHRU; } diff --git a/src/modules/m_showwhois.cpp b/src/modules/m_showwhois.cpp index be1871bad..074f1941c 100644 --- a/src/modules/m_showwhois.cpp +++ b/src/modules/m_showwhois.cpp @@ -110,7 +110,7 @@ class ModuleShowwhois : public Module if (!dest->IsModeSet('W') || source == dest) return; - if (!ShowWhoisFromOpers && (IS_OPER(source) != IS_OPER(dest))) + if (!ShowWhoisFromOpers && (!IS_OPER(source) != !IS_OPER(dest))) return; if (IS_LOCAL(dest)) |