From ae6acab1ba3ddc144c599d5434bbcf6f1efa37ad Mon Sep 17 00:00:00 2001 From: danieldg Date: Wed, 2 Sep 2009 00:46:36 +0000 Subject: [PATCH] Valgrind cleanup: deallocate RFC modes, clientlist, and uuidlist git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11614 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/mode.h | 1 + include/usermanager.h | 2 ++ src/inspircd.cpp | 2 +- src/mode.cpp | 23 +++++++++++++++++++++-- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/include/mode.h b/include/mode.h index a5a510367..da202c236 100644 --- a/include/mode.h +++ b/include/mode.h @@ -464,6 +464,7 @@ class CoreExport ModeParser : public classbase /** The constructor initializes all the RFC basic modes by using ModeParserAddMode(). */ ModeParser(InspIRCd* Instance); + ~ModeParser(); /** Used to check if user 'd' should be allowed to do operation 'MASK' on channel 'chan'. * for example, should 'user A' be able to 'op' on 'channel B'. diff --git a/include/usermanager.h b/include/usermanager.h index a6b5f74e4..8b396eab0 100644 --- a/include/usermanager.h +++ b/include/usermanager.h @@ -39,6 +39,8 @@ class CoreExport UserManager : public Extensible delete i->second; } clientlist->clear(); + delete clientlist; + delete uuidlist; } /** Client list, a hash_map containing all clients, local and remote diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 28aa0e1b9..10143b54b 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -82,7 +82,7 @@ const char* ExitCodes[] = "CreateEvent failed" /* 19 */ }; -template static void DeleteZero(T* n) +template static void DeleteZero(T*&n) { if (n != NULL) { diff --git a/src/mode.cpp b/src/mode.cpp index 1986ed2bb..cbd58021c 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -1086,19 +1086,22 @@ ModeParser::ModeParser(InspIRCd* Instance) : ServerInstance(Instance) new ModeChannelPrivate(Instance), new ModeChannelModerated(Instance), new ModeChannelTopicOps(Instance), + new ModeChannelNoExternal(Instance), new ModeChannelInviteOnly(Instance), new ModeChannelKey(Instance), new ModeChannelLimit(Instance), + new ModeChannelBan(Instance), new ModeChannelOp(Instance), new ModeChannelHalfOp(Instance), new ModeChannelVoice(Instance), + new ModeUserWallops(Instance), new ModeUserInvisible(Instance), new ModeUserOperator(Instance), new ModeUserServerNoticeMask(Instance), - NULL +#define BUILTIN_MODE_COUNT 16 }; /* Clear mode handler list */ @@ -1108,9 +1111,25 @@ ModeParser::ModeParser(InspIRCd* Instance) : ServerInstance(Instance) LastParse.clear(); /* Initialise the RFC mode letters */ - for (int index = 0; modes[index]; index++) + for (int index = 0; index < BUILTIN_MODE_COUNT; index++) this->AddMode(modes[index]); seq = 0; memset(&sent, 0, sizeof(sent)); } + +ModeParser::~ModeParser() +{ + int count = 0; + for(int i=0; i < 256; i++) + { + ModeHandler* mh = modehandlers[i]; + if (mh) + { + count++; + delete mh; + } + } + if (count != BUILTIN_MODE_COUNT) + throw CoreException("Mode handler found non-core modes remaining at deallocation"); +} -- 2.39.2