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

[or-cvs] prefer tor_free to free



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

Modified Files:
	circuitlist.c config.c connection.c directory.c dirserv.c 
	main.c onion.c router.c routerlist.c routerparse.c 
Log Message:
prefer tor_free to free
plus complain more loudly when we fail to parse a dir we just fetched


Index: circuitlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuitlist.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- circuitlist.c	3 Jul 2004 01:45:13 -0000	1.9
+++ circuitlist.c	29 Sep 2004 06:52:35 -0000	1.10
@@ -124,7 +124,7 @@
   }
 
   memset(circ, 0xAA, sizeof(circuit_t)); /* poison memory */
-  free(circ);
+  tor_free(circ);
 }
 
 /** Deallocate space associated with the linked list <b>cpath</b>. */
@@ -158,7 +158,7 @@
     crypto_free_digest_env(victim->b_digest);
   if(victim->handshake_state)
     crypto_dh_free(victim->handshake_state);
-  free(victim);
+  tor_free(victim);
 }
 
 /** Return a circ such that:

Index: config.c
===================================================================
RCS file: /home/or/cvsroot/src/or/config.c,v
retrieving revision 1.159
retrieving revision 1.160
diff -u -d -r1.159 -r1.160
--- config.c	23 Sep 2004 22:57:32 -0000	1.159
+++ config.c	29 Sep 2004 06:52:35 -0000	1.160
@@ -114,9 +114,9 @@
     tmp = front;
     front = tmp->next;
 
-    free(tmp->key);
-    free(tmp->value);
-    free(tmp);
+    tor_free(tmp->key);
+    tor_free(tmp->value);
+    tor_free(tmp);
   }
 }
 

Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.252
retrieving revision 1.253
diff -u -d -r1.252 -r1.253
--- connection.c	8 Sep 2004 06:52:33 -0000	1.252
+++ connection.c	29 Sep 2004 06:52:35 -0000	1.253
@@ -158,7 +158,7 @@
     tor_close_socket(conn->s);
   }
   memset(conn, 0xAA, sizeof(connection_t)); /* poison memory */
-  free(conn);
+  tor_free(conn);
 }
 
 /** Call connection_free() on every connection in our array.

Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/src/or/directory.c,v
retrieving revision 1.134
retrieving revision 1.135
diff -u -d -r1.134 -r1.135
--- directory.c	29 Sep 2004 05:48:25 -0000	1.134
+++ directory.c	29 Sep 2004 06:52:35 -0000	1.135
@@ -400,7 +400,7 @@
   if(parse_http_response(headers, &status_code, NULL, &date_header,
                          &compression) < 0) {
     log_fn(LOG_WARN,"Unparseable headers. Closing.");
-    free(body); free(headers);
+    tor_free(body); tor_free(headers);
     return -1;
   }
   if (date_header > 0) {
@@ -433,17 +433,17 @@
     log_fn(LOG_INFO,"Received directory (size %d):\n%s", body_len, body);
     if(status_code == 503 || body_len == 0) {
       log_fn(LOG_INFO,"Empty directory. Ignoring.");
-      free(body); free(headers);
+      tor_free(body); tor_free(headers);
       return 0;
     }
     if(status_code != 200) {
       log_fn(LOG_WARN,"Received http status code %d from dirserver. Failing.",
              status_code);
-      free(body); free(headers);
+      tor_free(body); tor_free(headers);
       return -1;
     }
     if(router_load_routerlist_from_directory(body, NULL) < 0){
-      log_fn(LOG_INFO,"...but parsing failed. Ignoring.");
+      log_fn(LOG_WARN,"I failed to parse the directory I fetched from %s:%d. Ignoring.", conn->address, conn->port);
     } else {
       log_fn(LOG_INFO,"updated routers.");
     }
@@ -458,12 +458,12 @@
     if(status_code != 200) {
       log_fn(LOG_WARN,"Received http status code %d from dirserver. Failing.",
              status_code);
-      free(body); free(headers);
+      tor_free(body); tor_free(headers);
       return -1;
     }
     if (!(rrs = router_parse_runningrouters(body))) {
       log_fn(LOG_WARN, "Can't parse runningrouters list");
-      free(body); free(headers);
+      tor_free(body); tor_free(headers);
       return -1;
     }
     router_get_routerlist(&rl);
@@ -526,7 +526,7 @@
         break;
     }
   }
-  free(body); free(headers);
+  tor_free(body); tor_free(headers);
   return 0;
 }
 

Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dirserv.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -d -r1.85 -r1.86
--- dirserv.c	28 Sep 2004 23:27:41 -0000	1.85
+++ dirserv.c	29 Sep 2004 06:52:35 -0000	1.86
@@ -275,7 +275,7 @@
   tor_free(desc->descriptor);
   tor_free(desc->nickname);
   routerinfo_free(desc->router);
-  free(desc);
+  tor_free(desc);
 }
 
 /** Release all storage that the dirserv is holding for server
@@ -594,7 +594,7 @@
            "running-routers %s\n\n",
            published, options.RecommendedVersions, cp);
 
-  free(cp);
+  tor_free(cp);
   i = strlen(s);
   cp = s+i;
 
@@ -749,7 +749,7 @@
     tor_cleanup();
     exit(0);
   }
-  free(new_directory);
+  tor_free(new_directory);
   if(get_data_directory(&options)) {
     snprintf(filename,sizeof(filename),"%s/cached-directory", get_data_directory(&options));
     if(write_str_to_file(filename,the_directory,0) < 0) {

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.329
retrieving revision 1.330
diff -u -d -r1.329 -r1.330
--- main.c	29 Sep 2004 05:59:55 -0000	1.329
+++ main.c	29 Sep 2004 06:52:35 -0000	1.330
@@ -297,7 +297,6 @@
 static void conn_close_if_marked(int i) {
   connection_t *conn;
   int retval;
-  struct in_addr in;
 
   conn = connection_array[i];
   assert_connection_ok(conn, time(NULL));
@@ -309,12 +308,11 @@
   if(conn->s >= 0 && connection_wants_to_flush(conn)) {
     /* -1 means it's an incomplete edge connection, or that the socket
      * has already been closed as unflushable. */
-    in.s_addr = htonl(conn->addr);
     if(!conn->hold_open_until_flushed)
       log_fn(LOG_INFO,
         "Conn (addr %s, fd %d, type %s, state %d) marked, but wants to flush %d bytes. "
         "(Marked at %s:%d)",
-        inet_ntoa(in), conn->s, CONN_TYPE_TO_STRING(conn->type), conn->state,
+        conn->address, conn->s, CONN_TYPE_TO_STRING(conn->type), conn->state,
         conn->outbuf_flushlen, conn->marked_for_close_file, conn->marked_for_close);
     if(connection_speaks_cells(conn)) {
       if(conn->state == OR_CONN_STATE_OPEN) {
@@ -332,7 +330,7 @@
     }
     if(connection_wants_to_flush(conn)) {
       log_fn(LOG_WARN,"Conn (addr %s, fd %d, type %s, state %d) still wants to flush. Losing %d bytes! (Marked at %s:%d)",
-             inet_ntoa(in), conn->s, CONN_TYPE_TO_STRING(conn->type), conn->state,
+             conn->address, conn->s, CONN_TYPE_TO_STRING(conn->type), conn->state,
              (int)buf_datalen(conn->outbuf), conn->marked_for_close_file,
              conn->marked_for_close);
     }

Index: onion.c
===================================================================
RCS file: /home/or/cvsroot/src/or/onion.c,v
retrieving revision 1.163
retrieving revision 1.164
diff -u -d -r1.163 -r1.164
--- onion.c	13 May 2004 07:24:49 -0000	1.163
+++ onion.c	29 Sep 2004 06:52:35 -0000	1.164
@@ -47,7 +47,7 @@
 
   if(ol_length >= options.MaxOnionsPending) {
     log_fn(LOG_WARN,"Already have %d onions queued. Closing.", ol_length);
-    free(tmp);
+    tor_free(tmp);
     return -1;
   }
 
@@ -109,7 +109,7 @@
 
   /* now victim points to the element that needs to be removed */
 
-  free(victim);
+  tor_free(victim);
 }
 
 /*----------------------------------------------------------------------*/

Index: router.c
===================================================================
RCS file: /home/or/cvsroot/src/or/router.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -d -r1.88 -r1.89
--- router.c	27 Sep 2004 06:00:43 -0000	1.88
+++ router.c	29 Sep 2004 06:52:35 -0000	1.89
@@ -767,7 +767,7 @@
            s);
     return -1;
   }
-  free(s_dup);
+  tor_free(s_dup);
   routerinfo_free(ri_tmp);
 #endif
 

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.143
retrieving revision 1.144
diff -u -d -r1.143 -r1.144
--- routerlist.c	28 Sep 2004 23:27:41 -0000	1.143
+++ routerlist.c	29 Sep 2004 06:52:35 -0000	1.144
@@ -540,7 +540,7 @@
   if (router->identity_pkey)
     crypto_free_pk_env(router->identity_pkey);
   exit_policy_free(router->exit_policy);
-  free(router);
+  tor_free(router);
 }
 
 /** Allocate a fresh copy of <b>router</b> */
@@ -717,12 +717,12 @@
 
   if(router_load_routerlist_from_string(string, trusted) < 0) {
     log_fn(LOG_WARN,"The routerfile itself was corrupt.");
-    free(string);
+    tor_free(string);
     return -1;
   }
   /* dump_onion_keys(LOG_NOTICE); */
 
-  free(string);
+  tor_free(string);
   return 0;
 }
 

Index: routerparse.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerparse.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- routerparse.c	28 Sep 2004 22:35:02 -0000	1.42
+++ routerparse.c	29 Sep 2004 06:52:36 -0000	1.43
@@ -872,7 +872,7 @@
  err:
   r = NULL;
  done:
-  free(tmp);
+  tor_free(tmp);
   token_free(tok);
   return r;
 }
@@ -1009,7 +1009,7 @@
   tor_assert(newe->string);
   log_fn(LOG_WARN,"Couldn't parse line '%s'. Dropping", newe->string);
   tor_free(newe->string);
-  free(newe);
+  tor_free(newe);
   return NULL;
 }