]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
core_whowas Delete elements of the per nick deque in the destructor of WhoWas::Nick
authorAttila Molnar <attilamolnar@hush.com>
Wed, 9 Jul 2014 13:00:31 +0000 (15:00 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Wed, 9 Jul 2014 13:00:31 +0000 (15:00 +0200)
include/commands/cmd_whowas.h
src/coremods/core_whowas.cpp

index b058ef37dbd315f0cae07eed6737acede75c1f40..2a3fa896c425f3366b6ddcc9ae7390972c4ff436 100644 (file)
@@ -39,6 +39,10 @@ namespace WhoWas
                /** Container where each element has information about one occurrence of this nick
                 */
                whowas_set entries;
+
+               /** Destructor, deallocates all elements in the entries container
+                */
+               ~Nick();
        };
 }
 
index 801f1186e0baac5942ee9fc881ef7a271dbb1656..0a418df3edfe2a06af0db67b4163f88d3c3dd71b 100644 (file)
@@ -118,8 +118,6 @@ void CommandWhowas::AddToWhoWas(User* user)
                        if (it != whowas.end())
                        {
                                WhoWas::Nick* set = it->second;
-                               stdalgo::delete_all(set->entries);
-
                                delete set;
                                whowas.erase(it);
                        }
@@ -162,8 +160,6 @@ void CommandWhowas::Prune()
                        }
 
                        WhoWas::Nick* nick = iter->second;
-                       stdalgo::delete_all(nick->entries);
-
                        delete nick;
                        whowas.erase(iter);
                        whowas_fifo.pop_front();
@@ -204,10 +200,6 @@ CommandWhowas::~CommandWhowas()
        for (whowas_users::iterator i = whowas.begin(); i != whowas.end(); ++i)
        {
                WhoWas::Nick* nick = i->second;
-               whowas_set* set = &nick->entries;
-               for (whowas_set::iterator j = set->begin(); j != set->end(); ++j)
-                       delete *j;
-
                delete nick;
        }
 }
@@ -217,6 +209,11 @@ WhoWasGroup::WhoWasGroup(User* user) : host(user->host), dhost(user->dhost), ide
 {
 }
 
+WhoWas::Nick::~Nick()
+{
+       stdalgo::delete_all(entries);
+}
+
 class ModuleWhoWas : public Module
 {
        CommandWhowas cmd;