summaryrefslogtreecommitdiff
path: root/src/modules/m_inviteexception.cpp
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-02 00:43:04 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-02 00:43:04 +0000
commit2630a87bb13b089e6d0fdcff4bcd0f3a9612e52f (patch)
tree8a780298dbc1311024047a2587fddcd0beafd2ca /src/modules/m_inviteexception.cpp
parentde87dec941cbf1eb6950a508876d654e2a3b63e4 (diff)
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
Diffstat (limited to 'src/modules/m_inviteexception.cpp')
-rw-r--r--src/modules/m_inviteexception.cpp24
1 files changed, 11 insertions, 13 deletions
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);
}
};