]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
qsockets are now dynamically allocated/freed, this drops memory use by about 2mb
authorlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 31 Jan 2002 12:16:59 +0000 (12:16 +0000)
committerlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 31 Jan 2002 12:16:59 +0000 (12:16 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@1451 d7cf8633-e32d-0410-b094-e92efae38249

net.h
net_dgrm.c
net_main.c

diff --git a/net.h b/net.h
index 105df0f534949571730751b6d1fcbf0a2e4618d2..c962f626280f38af58682bbd94a81e225d702565 100644 (file)
--- a/net.h
+++ b/net.h
@@ -126,7 +126,7 @@ typedef struct qsocket_s
        qboolean                disconnected;
        qboolean                canSend;
        qboolean                sendNext;
-       
+
        int                             driver;
        int                             landriver;
        int                             socket;
@@ -149,8 +149,10 @@ typedef struct qsocket_s
 } qsocket_t;
 
 extern qsocket_t       *net_activeSockets;
-extern qsocket_t       *net_freeSockets;
-extern int                     net_numsockets;
+// LordHavoc: sockets are dynamically allocated now
+//extern qsocket_t     *net_freeSockets;
+//extern int                   net_numsockets;
+extern mempool_t *net_mempool;
 
 typedef struct
 {
index 6b89add7ba9daa3a79e377ef503d631f1e7c4657..513c2561ec32201be33d66c524f03229f0f3309d 100644 (file)
@@ -487,18 +487,20 @@ void NET_Stats_f (void)
        {
                for (s = net_activeSockets; s; s = s->next)
                        PrintStats(s);
-               for (s = net_freeSockets; s; s = s->next)
-                       PrintStats(s);
+               // LordHavoc: sockets are dynamically allocated now
+               //for (s = net_freeSockets; s; s = s->next)
+               //      PrintStats(s);
        }
        else
        {
                for (s = net_activeSockets; s; s = s->next)
                        if (Q_strcasecmp(Cmd_Argv(1), s->address) == 0)
                                break;
-               if (s == NULL)
-                       for (s = net_freeSockets; s; s = s->next)
-                               if (Q_strcasecmp(Cmd_Argv(1), s->address) == 0)
-                                       break;
+               // LordHavoc: sockets are dynamically allocated now
+               //if (s == NULL)
+               //      for (s = net_freeSockets; s; s = s->next)
+               //              if (Q_strcasecmp(Cmd_Argv(1), s->address) == 0)
+               //                      break;
                if (s == NULL)
                        return;
                PrintStats(s);
index df40cad6b5dbd21c74218c5673b6a4e8dba0cbcc..516060d4ca245d0deefe528b690813f8a7ecd02c 100644 (file)
@@ -21,9 +21,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "quakedef.h"
 
-qsocket_t      *net_activeSockets = NULL;
-qsocket_t      *net_freeSockets = NULL;
-int                    net_numsockets = 0;
+qsocket_t *net_activeSockets = NULL;
+//qsocket_t *net_freeSockets = NULL;
+//int net_numsockets = 0;
+mempool_t *net_mempool;
 
 qboolean       ipxAvailable = false;
 qboolean       tcpipAvailable = false;
@@ -89,15 +90,17 @@ qsocket_t *NET_NewQSocket (void)
 {
        qsocket_t       *sock;
 
-       if (net_freeSockets == NULL)
-               return NULL;
+//     if (net_freeSockets == NULL)
+//             return NULL;
 
        if (net_activeconnections >= svs.maxclients)
                return NULL;
 
        // get one from free list
-       sock = net_freeSockets;
-       net_freeSockets = sock->next;
+//     sock = net_freeSockets;
+//     net_freeSockets = sock->next;
+       // LordHavoc: sockets are dynamically allocated now
+       sock = Mem_Alloc(net_mempool, sizeof(qsocket_t));
 
        // add it to active list
        sock->next = net_activeSockets;
@@ -144,9 +147,11 @@ void NET_FreeQSocket(qsocket_t *sock)
        }
 
        // add it to free list
-       sock->next = net_freeSockets;
-       net_freeSockets = sock;
-       sock->disconnected = true;
+//     sock->next = net_freeSockets;
+//     net_freeSockets = sock;
+//     sock->disconnected = true;
+       // LordHavoc: sockets are dynamically allocated now
+       Mem_Free(sock);
 }
 
 
@@ -556,7 +561,7 @@ int NET_SendMessage (qsocket_t *sock, sizebuf_t *data)
        r = sfunc.QSendMessage(sock, data);
        if (r == 1 && sock->driver)
                messagesSent++;
-       
+
        return r;
 }
 
@@ -691,13 +696,12 @@ NET_Init
 ====================
 */
 
-static mempool_t *net_mempool;
-
 void NET_Init (void)
 {
        int                     i;
        int                     controlSocket;
-       qsocket_t       *s;
+       // LordHavoc: sockets are dynamically allocated now
+       //qsocket_t     *s;
 
        i = COM_CheckParm ("-port");
        if (!i)
@@ -716,13 +720,16 @@ void NET_Init (void)
 
        if (COM_CheckParm("-listen") || cls.state == ca_dedicated)
                listening = true;
-       net_numsockets = svs.maxclientslimit;
-       if (cls.state != ca_dedicated)
-               net_numsockets++;
+       // LordHavoc: sockets are dynamically allocated now
+       //net_numsockets = svs.maxclientslimit;
+       //if (cls.state != ca_dedicated)
+       //      net_numsockets++;
 
        SetNetTime();
 
        net_mempool = Mem_AllocPool("qsocket");
+       // LordHavoc: sockets are dynamically allocated now
+       /*
        s = Mem_Alloc(net_mempool, net_numsockets * sizeof(qsocket_t));
        for (i = 0; i < net_numsockets; i++)
        {
@@ -731,6 +738,7 @@ void NET_Init (void)
                s->disconnected = true;
                s++;
        }
+       */
 
        // allocate space for network message buffer
        SZ_Alloc (&net_message, NET_MAXMESSAGE, "net_message");