From da45f24ff1ab4fbac1b674c820796e9b3850a380 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Fri, 14 Mar 2014 12:59:19 +0100 Subject: [PATCH] Change allocation of InspIRCd::chanlist to be physically part of the object containing it --- include/inspircd.h | 4 ++-- src/channels.cpp | 8 ++++---- src/helperfuncs.cpp | 4 ++-- src/inspircd.cpp | 4 ---- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/include/inspircd.h b/include/inspircd.h index cda15e619..1ceb64693 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -383,7 +383,7 @@ class CoreExport InspIRCd /** Channel list, a hash_map containing all channels XXX move to channel manager class */ - chan_hash* chanlist; + chan_hash chanlist; /** List of the open ports */ @@ -463,7 +463,7 @@ class CoreExport InspIRCd /** Get a hash map containing all channels, keyed by their name * @return A hash map mapping channel names to Channel pointers */ - chan_hash& GetChans() { return *chanlist; } + chan_hash& GetChans() { return chanlist; } /** Return true if a channel name is valid * @param chname A channel name to verify diff --git a/src/channels.cpp b/src/channels.cpp index 99c25fbfc..fcfb524ce 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -42,7 +42,7 @@ namespace Channel::Channel(const std::string &cname, time_t ts) : name(cname), age(ts), topicset(0) { - if (!ServerInstance->chanlist->insert(std::make_pair(cname, this)).second) + if (!ServerInstance->chanlist.insert(std::make_pair(cname, this)).second) throw CoreException("Cannot create duplicate channel " + cname); } @@ -88,12 +88,12 @@ void Channel::CheckDestroy() if (res == MOD_RES_DENY) return; - chan_hash::iterator iter = ServerInstance->chanlist->find(this->name); + chan_hash::iterator iter = ServerInstance->chanlist.find(this->name); /* kill the record */ - if (iter != ServerInstance->chanlist->end()) + if (iter != ServerInstance->chanlist.end()) { FOREACH_MOD(OnChannelDelete, (this)); - ServerInstance->chanlist->erase(iter); + ServerInstance->chanlist.erase(iter); } ClearInvites(); diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 6a831bb04..850eaf4c0 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -70,9 +70,9 @@ User *InspIRCd::FindUUID(const std::string &uid) Channel* InspIRCd::FindChan(const std::string &chan) { - chan_hash::iterator iter = chanlist->find(chan); + chan_hash::iterator iter = chanlist.find(chan); - if (iter == chanlist->end()) + if (iter == chanlist.end()) /* Couldn't find it */ return NULL; diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 101df432f..50899435b 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -138,7 +138,6 @@ void InspIRCd::Cleanup() DeleteZero(this->BanCache); DeleteZero(this->SNO); DeleteZero(this->Config); - DeleteZero(this->chanlist); DeleteZero(this->PI); DeleteZero(this->Threads); DeleteZero(this->Timers); @@ -266,7 +265,6 @@ InspIRCd::InspIRCd(int argc, char** argv) : this->Threads = 0; this->PI = 0; this->Users = 0; - this->chanlist = 0; this->Config = 0; this->SNO = 0; this->BanCache = 0; @@ -295,8 +293,6 @@ InspIRCd::InspIRCd(int argc, char** argv) : // Create base manager classes early, so nothing breaks this->Users = new UserManager; - this->chanlist = new chan_hash(); - this->Config = new ServerConfig; this->SNO = new SnomaskManager; this->BanCache = new BanCacheManager; -- 2.39.5