summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2003-11-18 08:20:19 +0000
committerRoger Dingledine <arma@torproject.org>2003-11-18 08:20:19 +0000
commitac56486bf64df4eb3264e87538ac415ce42eefd9 (patch)
treeddb0e7d6532602d991fcb6ac1d5919279063d30d
parentec02f83f9411f5737f1e77443d282c7e3feda0e4 (diff)
downloadtor-ac56486bf64df4eb3264e87538ac415ce42eefd9.tar.gz
tor-ac56486bf64df4eb3264e87538ac415ce42eefd9.zip
use the tor_malloc_zero wrapper
svn:r837
-rw-r--r--src/or/circuit.c3
-rw-r--r--src/or/connection.c8
-rw-r--r--src/or/connection_edge.c3
-rw-r--r--src/or/dirserv.c3
-rw-r--r--src/or/dns.c3
-rw-r--r--src/or/onion.c6
-rw-r--r--src/or/routers.c8
7 files changed, 13 insertions, 21 deletions
diff --git a/src/or/circuit.c b/src/or/circuit.c
index 5c2a263561..7849bda7fb 100644
--- a/src/or/circuit.c
+++ b/src/or/circuit.c
@@ -58,8 +58,7 @@ void circuit_remove(circuit_t *circ) {
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);
diff --git a/src/or/connection.c b/src/or/connection.c
index 299bd9ab00..e4685b787b 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -76,8 +76,7 @@ connection_t *connection_new(int type) {
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 @@ connection_t *connection_new(int type) {
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 @@ int connection_connect(connection_t *conn, char *address, uint32_t addr, uint16_
}
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);
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 4d36e07573..d28d6c1b26 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -672,7 +672,8 @@ static int connection_ap_handshake_socks_reply(connection_t *conn, char *reply,
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 */
}
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 74fef0d64d..42f1d57fa4 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -340,9 +340,8 @@ list_running_servers(char **nicknames_out)
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, " ");
diff --git a/src/or/dns.c b/src/or/dns.c
index 1199f7cc7c..94dd0dd72d 100644
--- a/src/or/dns.c
+++ b/src/or/dns.c
@@ -127,8 +127,7 @@ int dns_resolve(connection_t *exitconn) {
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);
diff --git a/src/or/onion.c b/src/or/onion.c
index 8cb2cddbe5..b50dd2bdc6 100644
--- a/src/or/onion.c
+++ b/src/or/onion.c
@@ -34,8 +34,7 @@ static int ol_length=0;
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 @@ int onion_extend_cpath(crypt_path_t **head_ptr, cpath_build_state_t *state, rout
}
/* 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) {
diff --git a/src/or/routers.c b/src/or/routers.c
index 9d6bc002f4..7ad0bb4247 100644
--- a/src/or/routers.c
+++ b/src/or/routers.c
@@ -763,8 +763,7 @@ routerinfo_t *router_get_entry_from_string(char**s) {
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 @@ static int router_add_exit_policy(routerinfo_t *router,
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 ");