[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] use the tor_malloc_zero wrapper



Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	circuit.c connection.c connection_edge.c dirserv.c dns.c 
	onion.c routers.c 
Log Message:
use the tor_malloc_zero wrapper


Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -d -r1.104 -r1.105
--- circuit.c	18 Nov 2003 07:48:00 -0000	1.104
+++ circuit.c	18 Nov 2003 08:20:19 -0000	1.105
@@ -58,8 +58,7 @@
 circuit_t *circuit_new(circ_id_t p_circ_id, connection_t *p_conn) {
   circuit_t *circ; 
 
-  circ = (circuit_t *)tor_malloc(sizeof(circuit_t));
-  memset(circ,0,sizeof(circuit_t)); /* zero it out */
+  circ = tor_malloc_zero(sizeof(circuit_t));
 
   circ->timestamp_created = time(NULL);
 

Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -d -r1.129 -r1.130
--- connection.c	11 Nov 2003 03:01:48 -0000	1.129
+++ connection.c	18 Nov 2003 08:20:19 -0000	1.130
@@ -76,8 +76,7 @@
   connection_t *conn;
   time_t now = time(NULL);
 
-  conn = (connection_t *)tor_malloc(sizeof(connection_t));
-  memset(conn,0,sizeof(connection_t)); /* zero it out to start */
+  conn = tor_malloc_zero(sizeof(connection_t));
   conn->s = -1; /* give it a default of 'not used' */
 
   conn->type = type;
@@ -86,8 +85,7 @@
     conn->outbuf = buf_new();
   }
   if (type == CONN_TYPE_AP) {
-    conn->socks_request = tor_malloc(sizeof(socks_request_t));
-    memset(conn->socks_request, 0, sizeof(socks_request_t));
+    conn->socks_request = tor_malloc_zero(sizeof(socks_request_t));
   }
 
   conn->timestamp_created = now;
@@ -264,7 +262,7 @@
   }
   set_socket_nonblocking(s);
 
-  memset((void *)&dest_addr,0,sizeof(dest_addr));
+  memset(&dest_addr,0,sizeof(dest_addr));
   dest_addr.sin_family = AF_INET;
   dest_addr.sin_port = htons(port);
   dest_addr.sin_addr.s_addr = htonl(addr);

Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- connection_edge.c	18 Nov 2003 00:02:24 -0000	1.63
+++ connection_edge.c	18 Nov 2003 08:20:19 -0000	1.64
@@ -672,7 +672,8 @@
     buf[1] = success ? SOCKS5_SUCCESS : SOCKS5_GENERIC_ERROR;
     buf[2] = 0;
     buf[3] = 1; /* ipv4 addr */
-    memset(buf+4,0,6); /* XXX set external addr/port to 0, see what breaks */
+    memset(buf+4,0,6); /* Set external addr/port to 0.
+                          The spec doesn't seem to say what to do here. -RD */
     connection_write_to_buf(buf,10,conn);
     return flush_buf(conn->s, conn->outbuf, &conn->outbuf_flushlen); /* try to flush it */
   }

Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dirserv.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- dirserv.c	13 Nov 2003 06:49:25 -0000	1.16
+++ dirserv.c	18 Nov 2003 08:20:19 -0000	1.17
@@ -340,9 +340,8 @@
   for (i = 0; i<n; ++i) {
     length += strlen(nickname_lst[i]);
   }
-  *nicknames_out = tor_malloc(length);
+  *nicknames_out = tor_malloc_zero(length);
   cp = *nicknames_out;
-  memset(cp,0,length);
   for (i = 0; i<n; ++i) {
     if (i)
       strcat(cp, " ");

Index: dns.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dns.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- dns.c	13 Nov 2003 06:49:25 -0000	1.39
+++ dns.c	18 Nov 2003 08:20:19 -0000	1.40
@@ -127,8 +127,7 @@
         return -1;
     }
   } else { /* need to add it */
-    resolve = tor_malloc(sizeof(struct cached_resolve));
-    memset(resolve, 0, sizeof(struct cached_resolve));
+    resolve = tor_malloc_zero(sizeof(struct cached_resolve));
     resolve->state = CACHE_STATE_PENDING;
     resolve->expire = now + 15*60; /* 15 minutes */
     strncpy(resolve->question, exitconn->address, MAX_ADDRESSLEN);

Index: onion.c
===================================================================
RCS file: /home/or/cvsroot/src/or/onion.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -d -r1.89 -r1.90
--- onion.c	17 Nov 2003 08:15:37 -0000	1.89
+++ onion.c	18 Nov 2003 08:20:19 -0000	1.90
@@ -34,8 +34,7 @@
 int onion_pending_add(circuit_t *circ) {
   struct onion_queue_t *tmp;
 
-  tmp = tor_malloc(sizeof(struct onion_queue_t));
-  memset(tmp, 0, sizeof(struct onion_queue_t));
+  tmp = tor_malloc_zero(sizeof(struct onion_queue_t));
   tmp->circ = circ;
 
   if(!ol_tail) {
@@ -460,8 +459,7 @@
   }
  
   /* Okay, so we haven't used 'choice' before. */
-  hop = (crypt_path_t *)tor_malloc(sizeof(crypt_path_t));
-  memset(hop, 0, sizeof(crypt_path_t));
+  hop = (crypt_path_t *)tor_malloc_zero(sizeof(crypt_path_t));
 
   /* link hop into the cpath, at the end. */
   if (*head_ptr) {

Index: routers.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routers.c,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -d -r1.94 -r1.95
--- routers.c	18 Nov 2003 06:51:29 -0000	1.94
+++ routers.c	18 Nov 2003 08:20:19 -0000	1.95
@@ -763,8 +763,7 @@
     return NULL;
   }
 
-  router = tor_malloc(sizeof(routerinfo_t));
-  memset(router,0,sizeof(routerinfo_t)); /* zero it out first */
+  router = tor_malloc_zero(sizeof(routerinfo_t));
   router->onion_pkey = router->identity_pkey = router->link_pkey = NULL; 
 
   if (tok->val.cmd.n_args != 6) {
@@ -970,9 +969,8 @@
     return -1;
   arg = tok->val.cmd.args[0];
 
-  newe = tor_malloc(sizeof(struct exit_policy_t));
-  memset(newe,0,sizeof(struct exit_policy_t));
-  
+  newe = tor_malloc_zero(sizeof(struct exit_policy_t));
+
   newe->string = tor_malloc(8+strlen(arg));
   if (tok->tp == K_REJECT) {
     strcpy(newe->string, "reject ");