]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Change allocation of UserManager::clientlist to be physically part of the object...
authorAttila Molnar <attilamolnar@hush.com>
Sat, 15 Mar 2014 14:29:25 +0000 (15:29 +0100)
committerAttila Molnar <attilamolnar@hush.com>
Sat, 15 Mar 2014 14:29:25 +0000 (15:29 +0100)
include/usermanager.h
src/helperfuncs.cpp
src/modules/m_spanningtree/uid.cpp
src/usermanager.cpp
src/users.cpp

index 15d41e6bc4b6b6a7ebb472338625d13b73adcd17..040f91852a73ab024e71189c7d9157a851819a62 100644 (file)
@@ -32,18 +32,17 @@ class CoreExport UserManager
        clonemap local_clones;
 
  public:
-       /** Constructor, initializes variables and allocates the hashmaps
+       /** Constructor, initializes variables
         */
        UserManager();
 
-       /** Destructor, destroys all users in clientlist and then deallocates
-        * the hashmaps
+       /** Destructor, destroys all users in clientlist
         */
        ~UserManager();
 
        /** Client list, a hash_map containing all clients, local and remote
         */
-       user_hash* clientlist;
+       user_hash clientlist;
 
        /** Client list stored by UUID. Contains all clients, and is updated
         * automatically by the constructor and destructor of User.
@@ -135,12 +134,12 @@ class CoreExport UserManager
        /** Return a count of all global users, unknown and known connections
         * @return The number of users on the network, including local unregistered users
         */
-       unsigned int UserCount() const { return this->clientlist->size(); }
+       unsigned int UserCount() const { return this->clientlist.size(); }
 
        /** Return a count of fully registered connections on the network
         * @return The number of registered users on the network
         */
-       unsigned int RegisteredUserCount() { return this->clientlist->size() - this->UnregisteredUserCount(); }
+       unsigned int RegisteredUserCount() { return this->clientlist.size() - this->UnregisteredUserCount(); }
 
        /** Return a count of opered (umode +o) users on the network
         * @return The number of opers on the network
@@ -160,7 +159,7 @@ class CoreExport UserManager
        /** Get a hash map containing all users, keyed by their nickname
         * @return A hash map mapping nicknames to User pointers
         */
-       user_hash& GetUsers() { return *clientlist; }
+       user_hash& GetUsers() { return clientlist; }
 
        /** Send a server notice to all local users
         * @param text The text format string to send
index 567806efcef407ded6176ab17e3514aac5ec8af7..bebb22007b9558f4a054e00f887c0dbb6873c0f2 100644 (file)
@@ -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;
index 37c54ae601770debbf38b68172d2e6b20006bff0..f248b3860743880d0e2720d8c9852e0faac5ba5d 100644 (file)
@@ -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];
index 2a9f02cfdbe5893f350180011978e6dd9efbba91..ee6eafbb58d6aacb463fc30a661c28cdc0bd1f5a 100644 (file)
 #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);
index e760a3fbc3284e219964f921239edfeea5392854..6a31f0a93f02027a2f99e5dcf79bc9b091c1c974 100644 (file)
@@ -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));