[cvslog] Module eggdrop1.7: Change committed

cvslog cvs at tsss.org
Sun Oct 21 16:01:01 CST 2001


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.7
Commit time: 2001-10-21 21:00:00 UTC
Commited by: stdarg <stdarg at techmonkeys.org>

Modified files:
     src/dccutil.c src/tcldcc.c

Log message:

* dcc array is now sparse

---------------------- diff included ----------------------
Index: eggdrop1.7/src/dccutil.c
diff -u eggdrop1.7/src/dccutil.c:1.39 eggdrop1.7/src/dccutil.c:1.40
--- eggdrop1.7/src/dccutil.c:1.39	Thu Oct 18 20:55:05 2001
+++ eggdrop1.7/src/dccutil.c	Sun Oct 21 15:59:49 2001
@@ -6,7 +6,7 @@
  *   memory management for dcc structures
  *   timeout checking for dcc connections
  *
- * $Id: dccutil.c,v 1.39 2001/10/19 01:55:05 tothwolf Exp $
+ * $Id: dccutil.c,v 1.40 2001/10/21 20:59:49 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -274,11 +274,8 @@
     dcc[n].type->kill(n, dcc[n].u.other);
   else if (dcc[n].u.other)
     free(dcc[n].u.other);
-  dcc_total--;
-  if (n < dcc_total)
-    memcpy(&dcc[n], &dcc[dcc_total], sizeof(struct dcc_t));
-  else
-    memset(&dcc[n], 0, sizeof(struct dcc_t)); /* drummer */
+
+  memset(&dcc[n], 0, sizeof(struct dcc_t)); /* drummer */
 }
 
 /* Clean up sockets that were just left for dead.
@@ -290,7 +287,6 @@
   for (i = 0; i < dcc_total; i++) {
     if (dcc[i].type == &DCC_LOST) {
       dcc[i].type = NULL;
-      dcc[i].sock = (-1);
       removedcc(i);
       i--;
     }
@@ -313,6 +309,7 @@
   spaces[HANDLEN - 9] = ' ';
   /* Show server */
   for (i = 0; i < dcc_total; i++) {
+    if (!dcc[i].type) continue;
     j = strlen(dcc[i].host);
     if (j > 26)
       j -= 26;
@@ -326,7 +323,7 @@
     }
     k = HANDLEN - strlen(dcc[i].nick);
     spaces[k] = 0;
-    dprintf(zidx, "%-4d %5d %s%s %-26s %s\n", dcc[i].sock,
+    dprintf(zidx, "%-4d %5d %s%s %-26s %s\n", i,
 	    dcc[i].port, dcc[i].nick, spaces, dcc[i].host + j, other);
     spaces[k] = ' ';
   }
@@ -414,10 +411,18 @@
 {
   int i = dcc_total;
 
-  if (dcc_total == max_dcc)
-    return -1;
-  dcc_total++;
-  memset((char *) &dcc[i], 0, sizeof(struct dcc_t));
+  for (i = 0; i < dcc_total; i++) {
+    if (!dcc[i].type) break;
+  }
+  if (i == dcc_total) {
+    if (dcc_total == max_dcc) {
+      max_dcc += 5;
+      dcc = (struct dcc_t *)realloc(dcc, max_dcc * sizeof(*dcc));
+      memset(dcc+dcc_total, 0, 5 * sizeof(*dcc));
+    }
+    dcc_total++;
+  }
+  memset(&dcc[i], 0, sizeof(*dcc));
 
   dcc[i].type = type;
   if (xtra_size)
Index: eggdrop1.7/src/tcldcc.c
diff -u eggdrop1.7/src/tcldcc.c:1.37 eggdrop1.7/src/tcldcc.c:1.38
--- eggdrop1.7/src/tcldcc.c:1.37	Sun Oct 21 14:51:41 2001
+++ eggdrop1.7/src/tcldcc.c	Sun Oct 21 15:59:49 2001
@@ -2,7 +2,7 @@
  * tcldcc.c -- handles:
  *   Tcl stubs for the dcc commands
  *
- * $Id: tcldcc.c,v 1.37 2001/10/21 19:51:41 stdarg Exp $
+ * $Id: tcldcc.c,v 1.38 2001/10/21 20:59:49 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -51,7 +51,7 @@
 
   BADARGS(3, 3, " idx text");
   idx = atoi(argv[1]);
-  if (idx < 0 ||  idx >= dcc_total || dcc[idx].sock == -1) {
+  if (idx < 0 ||  idx >= dcc_total || !dcc[idx].type) {
     Tcl_AppendResult(irp, "invalid idx", NULL);
     return TCL_ERROR;
   }
@@ -85,7 +85,7 @@
       }
     }
   }
-  if (idx < 0 || idx >= dcc_total || dcc[idx].sock == -1) {
+  if (idx < 0 || idx >= dcc_total || !dcc[idx].type) {
     Tcl_AppendResult(irp, "invalid idx", NULL);
     return TCL_ERROR;
   }
----------------------- End of diff -----------------------



More information about the Changes mailing list