]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Correctly use iterators and pointer to ucrec
[user/henk/code/inspircd.git] / src / users.cpp
index 94ed97d93f9b3b0f4df0c0defb63bcd8ebc62c88..5c1d78fb020a37e4433dcf7416a4d725a440f7cc 100644 (file)
@@ -113,10 +113,23 @@ userrec::userrec()
        sendq = "";
        chans.clear();
        invites.clear();
+        chans.resize(MAXCHANS);
+        for (unsigned int n = 0; n < MAXCHANS; n++)
+        {
+               ucrec* x = new ucrec();
+               chans[n] = x;
+               x->channel = NULL;
+               x->uc_modes = 0;
+        }
 }
 
 userrec::~userrec()
 {
+       for (std::vector<ucrec*>::iterator n = chans.begin(); n != chans.end(); n++)
+       {
+               ucrec* x = (ucrec*)*n;
+               delete x;
+       }
 }
 
 void userrec::MakeHost(char* nhost)
@@ -616,11 +629,6 @@ void AddClient(int socket, int port, bool iscached, in_addr ip4)
         clientlist[tempnick]->sendqmax = class_sqmax;
         clientlist[tempnick]->recvqmax = class_rqmax;
 
-        ucrec a;
-        a.channel = NULL;
-        a.uc_modes = 0;
-       clientlist[tempnick]->chans.resize(MAXCHANS);
-
        fd_ref_table[socket] = clientlist[tempnick];
        local_users.push_back(clientlist[tempnick]);