diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-03-15 15:29:25 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-03-15 15:29:25 +0100 |
commit | ea590a5d80741c3bc030cb0a2fcb3c59da4fd078 (patch) | |
tree | 6be464e4511cc58c8f7aecc19c485f847a6b387e /src | |
parent | 66965131f834d14104ad618fd6d89bfd912cd120 (diff) |
Change allocation of UserManager::clientlist to be physically part of the object containing it
Diffstat (limited to 'src')
-rw-r--r-- | src/helperfuncs.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_spanningtree/uid.cpp | 2 | ||||
-rw-r--r-- | src/usermanager.cpp | 15 | ||||
-rw-r--r-- | src/users.cpp | 8 |
4 files changed, 13 insertions, 20 deletions
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 567806efc..bebb22007 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -38,9 +38,9 @@ User* InspIRCd::FindNick(const std::string &nick) if (!nick.empty() && isdigit(*nick.begin())) return FindUUID(nick); - user_hash::iterator iter = this->Users->clientlist->find(nick); + user_hash::iterator iter = this->Users->clientlist.find(nick); - if (iter == this->Users->clientlist->end()) + if (iter == this->Users->clientlist.end()) /* Couldn't find it */ return NULL; @@ -49,9 +49,9 @@ User* InspIRCd::FindNick(const std::string &nick) User* InspIRCd::FindNickOnly(const std::string &nick) { - user_hash::iterator iter = this->Users->clientlist->find(nick); + user_hash::iterator iter = this->Users->clientlist.find(nick); - if (iter == this->Users->clientlist->end()) + if (iter == this->Users->clientlist.end()) return NULL; return iter->second; diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp index 37c54ae60..f248b3860 100644 --- a/src/modules/m_spanningtree/uid.cpp +++ b/src/modules/m_spanningtree/uid.cpp @@ -77,7 +77,7 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, std::vector<std::st ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Duplicate UUID %s in client introduction", params[0].c_str()); return CMD_INVALID; } - (*(ServerInstance->Users->clientlist))[params[2]] = _new; + ServerInstance->Users->clientlist[params[2]] = _new; _new->nick = params[2]; _new->host = params[3]; _new->dhost = params[4]; diff --git a/src/usermanager.cpp b/src/usermanager.cpp index 2a9f02cfd..ee6eafbb5 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -26,19 +26,16 @@ #include "iohook.h" UserManager::UserManager() - : clientlist(new user_hash) - , unregistered_count(0) + : unregistered_count(0) { } UserManager::~UserManager() { - for (user_hash::iterator i = clientlist->begin(); i != clientlist->end(); ++i) + for (user_hash::iterator i = clientlist.begin(); i != clientlist.end(); ++i) { delete i->second; } - - delete clientlist; } /* add a client connection to the sockets list */ @@ -70,7 +67,7 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs /* The users default nick is their UUID */ New->nick = New->uuid; - (*(this->clientlist))[New->nick] = New; + this->clientlist[New->nick] = New; New->registered = REG_NONE; New->signon = ServerInstance->Time() + ServerInstance->Config->dns_timeout; @@ -199,11 +196,7 @@ void UserManager::QuitUser(User* user, const std::string& quitreason, const std: ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s (%s) [%s]", user->GetFullRealHost().c_str(), user->GetIPString().c_str(), operreason->c_str()); } - user_hash::iterator iter = this->clientlist->find(user->nick); - - if (iter != this->clientlist->end()) - this->clientlist->erase(iter); - else + if (!clientlist.erase(user->nick)) ServerInstance->Logs->Log("USERS", LOG_DEFAULT, "ERROR: Nick not found in clientlist, cannot remove: " + user->nick); uuidlist.erase(user->uuid); diff --git a/src/users.cpp b/src/users.cpp index e760a3fbc..6a31f0a93 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -697,8 +697,8 @@ bool User::ChangeNick(const std::string& newnick, bool force, time_t newts) InUse->WriteTo(InUse, "NICK %s", InUse->uuid.c_str()); InUse->WriteNumeric(ERR_NICKNAMEINUSE, "%s :Nickname overruled.", InUse->nick.c_str()); - ServerInstance->Users->clientlist->erase(InUse->nick); - (*(ServerInstance->Users->clientlist))[InUse->uuid] = InUse; + ServerInstance->Users->clientlist.erase(InUse->nick); + ServerInstance->Users->clientlist[InUse->uuid] = InUse; InUse->nick = InUse->uuid; InUse->InvalidateCache(); @@ -721,8 +721,8 @@ bool User::ChangeNick(const std::string& newnick, bool force, time_t newts) nick = newnick; InvalidateCache(); - ServerInstance->Users->clientlist->erase(oldnick); - (*(ServerInstance->Users->clientlist))[newnick] = this; + ServerInstance->Users->clientlist.erase(oldnick); + ServerInstance->Users->clientlist[newnick] = this; if (registered == REG_ALL) FOREACH_MOD(OnUserPostNick, (this,oldnick)); |