diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-09-02 00:43:04 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-09-02 00:43:04 +0000 |
commit | 2630a87bb13b089e6d0fdcff4bcd0f3a9612e52f (patch) | |
tree | 8a780298dbc1311024047a2587fddcd0beafd2ca /src/modules/m_services_account.cpp | |
parent | de87dec941cbf1eb6950a508876d654e2a3b63e4 (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_services_account.cpp')
-rw-r--r-- | src/modules/m_services_account.cpp | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp index 7aebaa1b9..d6cf0b1e7 100644 --- a/src/modules/m_services_account.cpp +++ b/src/modules/m_services_account.cpp @@ -99,21 +99,19 @@ class AChannel_M : public SimpleChannelModeHandler class ModuleServicesAccount : public Module { - AChannel_R* m1; - AChannel_M* m2; - AUser_R* m3; - Channel_r *m4; - User_r *m5; + AChannel_R m1; + AChannel_M m2; + AUser_R m3; + Channel_r m4; + User_r m5; public: - ModuleServicesAccount(InspIRCd* Me) : Module(Me) + ModuleServicesAccount(InspIRCd* Me) : Module(Me), + m1(Me), m2(Me), m3(Me), m4(Me), m5(Me) { - m1 = new AChannel_R(ServerInstance); - m2 = new AChannel_M(ServerInstance); - m3 = new AUser_R(ServerInstance); - m4 = new Channel_r(ServerInstance); - m5 = new User_r(ServerInstance); - if (!ServerInstance->Modes->AddMode(m1) || !ServerInstance->Modes->AddMode(m2) || !ServerInstance->Modes->AddMode(m3) || !ServerInstance->Modes->AddMode(m4) || !ServerInstance->Modes->AddMode(m5)) + if (!ServerInstance->Modes->AddMode(&m1) || !ServerInstance->Modes->AddMode(&m2) || + !ServerInstance->Modes->AddMode(&m3) || !ServerInstance->Modes->AddMode(&m4) || + !ServerInstance->Modes->AddMode(&m5)) throw ModuleException("Some other module has claimed our modes!"); Implementation eventlist[] = { I_OnWhois, I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserPreJoin, I_OnCheckBan, @@ -347,16 +345,11 @@ class ModuleServicesAccount : public Module virtual ~ModuleServicesAccount() { - ServerInstance->Modes->DelMode(m1); - ServerInstance->Modes->DelMode(m2); - ServerInstance->Modes->DelMode(m3); - ServerInstance->Modes->DelMode(m4); - ServerInstance->Modes->DelMode(m5); - delete m1; - delete m2; - delete m3; - delete m4; - delete m5; + ServerInstance->Modes->DelMode(&m1); + ServerInstance->Modes->DelMode(&m2); + ServerInstance->Modes->DelMode(&m3); + ServerInstance->Modes->DelMode(&m4); + ServerInstance->Modes->DelMode(&m5); } virtual Version GetVersion() |