]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Valgrind cleanup: deallocate RFC modes, clientlist, and uuidlist
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 2 Sep 2009 00:46:36 +0000 (00:46 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 2 Sep 2009 00:46:36 +0000 (00:46 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11614 e03df62e-2008-0410-955e-edbf42e46eb7

include/mode.h
include/usermanager.h
src/inspircd.cpp
src/mode.cpp

index a5a51036748c51a04f55a5be6c79fafeaf713392..da202c2364c5f09e2a2703f36ef72d878a3bc50c 100644 (file)
@@ -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'.
index a6b5f74e4fbde68a165825a77725131be4036f7c..8b396eab039156afdf456326fee14592f7a93957 100644 (file)
@@ -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
index 28aa0e1b907707016ef8b0de2d9a6f9e03947ad8..10143b54b8e55040c6e8cc044eddef18675cc5b6 100644 (file)
@@ -82,7 +82,7 @@ const char* ExitCodes[] =
                "CreateEvent failed" /* 19 */
 };
 
-template<typename T> static void DeleteZero(T* n)
+template<typename T> static void DeleteZero(T*&n)
 {
        if (n != NULL)
        {
index 1986ed2bbe0b90c8fc7f057c120695dd0d87547f..cbd58021cb27d73fe57d2ff4aa68b7d650b5adbb 100644 (file)
@@ -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");
+}