From 3a67168036e1d8e0406c66c3ccf37812228a9524 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Wed, 9 Jul 2014 15:00:31 +0200 Subject: [PATCH] core_whowas Delete elements of the per nick deque in the destructor of WhoWas::Nick --- include/commands/cmd_whowas.h | 4 ++++ src/coremods/core_whowas.cpp | 13 +++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/commands/cmd_whowas.h b/include/commands/cmd_whowas.h index b058ef37d..2a3fa896c 100644 --- a/include/commands/cmd_whowas.h +++ b/include/commands/cmd_whowas.h @@ -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(); }; } diff --git a/src/coremods/core_whowas.cpp b/src/coremods/core_whowas.cpp index 801f1186e..0a418df3e 100644 --- a/src/coremods/core_whowas.cpp +++ b/src/coremods/core_whowas.cpp @@ -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; -- 2.39.5