From 2630a87bb13b089e6d0fdcff4bcd0f3a9612e52f Mon Sep 17 00:00:00 2001 From: danieldg Date: Wed, 2 Sep 2009 00:43:04 +0000 Subject: Change allocation of commands/modes API change: Commands passed to AddCommand are no longer deleted automatically This removes lots of needless heap allocation and fixes a few memory leaks by allocating commands and modes as part of the Module rather than creating them separately in the module constructor. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11592 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_inviteexception.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'src/modules/m_inviteexception.cpp') diff --git a/src/modules/m_inviteexception.cpp b/src/modules/m_inviteexception.cpp index 130ca9a43..5acdf4f97 100644 --- a/src/modules/m_inviteexception.cpp +++ b/src/modules/m_inviteexception.cpp @@ -39,16 +39,15 @@ class InviteException : public ListModeBase class ModuleInviteException : public Module { - InviteException* ie; + InviteException ie; public: - ModuleInviteException(InspIRCd* Me) : Module(Me) + ModuleInviteException(InspIRCd* Me) : Module(Me), ie(Me) { - ie = new InviteException(ServerInstance); - if (!ServerInstance->Modes->AddMode(ie)) + if (!ServerInstance->Modes->AddMode(&ie)) throw ModuleException("Could not add new modes!"); ServerInstance->Modules->PublishInterface("ChannelBanList", this); - ie->DoImplements(this); + ie.DoImplements(this); Implementation eventlist[] = { I_OnRequest, I_On005Numeric, I_OnCheckInvite }; ServerInstance->Modules->Attach(eventlist, this, 3); } @@ -63,7 +62,7 @@ public: if(chan != NULL) { modelist* list; - chan->GetExt(ie->GetInfoKey(), list); + chan->GetExt(ie.GetInfoKey(), list); if (list) { std::string mask = std::string(user->nick) + "!" + user->ident + "@" + user->GetIPString(); @@ -84,27 +83,27 @@ public: virtual const char* OnRequest(Request* request) { - return ie->DoOnRequest(request); + return ie.DoOnRequest(request); } virtual void OnCleanup(int target_type, void* item) { - ie->DoCleanup(target_type, item); + ie.DoCleanup(target_type, item); } virtual void OnSyncChannel(Channel* chan, Module* proto, void* opaque) { - ie->DoSyncChannel(chan, proto, opaque); + ie.DoSyncChannel(chan, proto, opaque); } virtual void OnChannelDelete(Channel* chan) { - ie->DoChannelDelete(chan); + ie.DoChannelDelete(chan); } virtual void OnRehash(User* user) { - ie->DoRehash(); + ie.DoRehash(); } virtual Version GetVersion() @@ -114,8 +113,7 @@ public: ~ModuleInviteException() { - ServerInstance->Modes->DelMode(ie); - delete ie; + ServerInstance->Modes->DelMode(&ie); ServerInstance->Modules->UnpublishInterface("ChannelBanList", this); } }; -- cgit v1.2.3