summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-09-29 06:52:36 +0000
committerRoger Dingledine <arma@torproject.org>2004-09-29 06:52:36 +0000
commit136d4e573913480491e0c45ffe7ff6450cb107af (patch)
tree000b359e41d9c491f629831db2fe45af89d4448f
parent6ed095b17769c56d8bd5c92d080e2a839c04b9e5 (diff)
downloadtor-136d4e573913480491e0c45ffe7ff6450cb107af.tar.gz
tor-136d4e573913480491e0c45ffe7ff6450cb107af.zip
prefer tor_free to free
plus complain more loudly when we fail to parse a dir we just fetched svn:r2401
-rw-r--r--src/or/circuitlist.c4
-rw-r--r--src/or/config.c6
-rw-r--r--src/or/connection.c2
-rw-r--r--src/or/directory.c14
-rw-r--r--src/or/dirserv.c6
-rw-r--r--src/or/main.c6
-rw-r--r--src/or/onion.c4
-rw-r--r--src/or/router.c2
-rw-r--r--src/or/routerlist.c6
-rw-r--r--src/or/routerparse.c4
10 files changed, 26 insertions, 28 deletions
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index 8c40b53eca..f66a4b9900 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -124,7 +124,7 @@ static void circuit_free(circuit_t *circ) {
}
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 @@ void circuit_free_cpath_node(crypt_path_t *victim) {
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:
diff --git a/src/or/config.c b/src/or/config.c
index 9b7afee2f2..c605d2b42c 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -114,9 +114,9 @@ static void config_free_lines(struct config_line_t *front) {
tmp = front;
front = tmp->next;
- free(tmp->key);
- free(tmp->value);
- free(tmp);
+ tor_free(tmp->key);
+ tor_free(tmp->value);
+ tor_free(tmp);
}
}
diff --git a/src/or/connection.c b/src/or/connection.c
index 839da4310c..3ed6b8bc9f 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -158,7 +158,7 @@ void connection_free(connection_t *conn) {
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.
diff --git a/src/or/directory.c b/src/or/directory.c
index 3d0c2005e6..62958d5790 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -400,7 +400,7 @@ connection_dir_client_reached_eof(connection_t *conn)
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 @@ connection_dir_client_reached_eof(connection_t *conn)
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 @@ connection_dir_client_reached_eof(connection_t *conn)
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 @@ connection_dir_client_reached_eof(connection_t *conn)
break;
}
}
- free(body); free(headers);
+ tor_free(body); tor_free(headers);
return 0;
}
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 067554ffd3..ec4e8d3b01 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -275,7 +275,7 @@ static void free_descriptor_entry(descriptor_entry_t *desc)
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 @@ dirserv_dump_directory_to_string(char *s, unsigned int maxlen,
"running-routers %s\n\n",
published, options.RecommendedVersions, cp);
- free(cp);
+ tor_free(cp);
i = strlen(s);
cp = s+i;
@@ -749,7 +749,7 @@ static int dirserv_regenerate_directory(void)
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) {
diff --git a/src/or/main.c b/src/or/main.c
index 87924da0ea..bef042cd2e 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -297,7 +297,6 @@ static void conn_write(int i) {
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 @@ static void conn_close_if_marked(int i) {
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 @@ static void conn_close_if_marked(int i) {
}
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);
}
diff --git a/src/or/onion.c b/src/or/onion.c
index 8cf0073540..39deae2db7 100644
--- a/src/or/onion.c
+++ b/src/or/onion.c
@@ -47,7 +47,7 @@ int onion_pending_add(circuit_t *circ) {
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 @@ void onion_pending_remove(circuit_t *circ) {
/* now victim points to the element that needs to be removed */
- free(victim);
+ tor_free(victim);
}
/*----------------------------------------------------------------------*/
diff --git a/src/or/router.c b/src/or/router.c
index 38e741e30b..e37c20902e 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -767,7 +767,7 @@ int router_dump_router_to_string(char *s, int maxlen, routerinfo_t *router,
s);
return -1;
}
- free(s_dup);
+ tor_free(s_dup);
routerinfo_free(ri_tmp);
#endif
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 63a72d1ca9..7f8261595d 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -540,7 +540,7 @@ void routerinfo_free(routerinfo_t *router)
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 @@ int router_load_routerlist_from_file(char *routerfile, int trusted)
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;
}
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 20572545f9..773340dea0 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -872,7 +872,7 @@ router_parse_exit_policy_from_string(const char *s)
err:
r = NULL;
done:
- free(tmp);
+ tor_free(tmp);
token_free(tok);
return r;
}
@@ -1009,7 +1009,7 @@ policy_read_failed:
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;
}