summaryrefslogtreecommitdiff
path: root/src/or/dirvote.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-08-13 10:36:06 -0400
committerNick Mathewson <nickm@torproject.org>2014-08-13 10:39:56 -0400
commit2bfd92d0d170642fb12f53e5da208f318fdd632c (patch)
tree09da23f22e58e196fef9995e21b59aff3b555487 /src/or/dirvote.c
parent5da821a8a3cfffc18f5a656852d98e69cff5dd8f (diff)
downloadtor-2bfd92d0d170642fb12f53e5da208f318fdd632c.tar.gz
tor-2bfd92d0d170642fb12f53e5da208f318fdd632c.zip
Apply coccinelle script to replace malloc(a*b)->calloc(a,b)
Diffstat (limited to 'src/or/dirvote.c')
-rw-r--r--src/or/dirvote.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index c7be343ca2..30f132115b 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -607,7 +607,7 @@ dirvote_compute_params(smartlist_t *votes, int method, int total_authorities)
between INT32_MIN and INT32_MAX inclusive. This should be guaranteed by
the parsing code. */
- vals = tor_malloc(sizeof(int)*n_votes);
+ vals = tor_calloc(sizeof(int), n_votes);
SMARTLIST_FOREACH_BEGIN(votes, networkstatus_t *, v) {
if (!v->net_params)
@@ -1353,11 +1353,11 @@ networkstatus_compute_consensus(smartlist_t *votes,
* routers we might need to talk about. */
{
int n_votes = smartlist_len(votes);
- time_t *va_times = tor_malloc(n_votes * sizeof(time_t));
- time_t *fu_times = tor_malloc(n_votes * sizeof(time_t));
- time_t *vu_times = tor_malloc(n_votes * sizeof(time_t));
- int *votesec_list = tor_malloc(n_votes * sizeof(int));
- int *distsec_list = tor_malloc(n_votes * sizeof(int));
+ time_t *va_times = tor_calloc(n_votes, sizeof(time_t));
+ time_t *fu_times = tor_calloc(n_votes, sizeof(time_t));
+ time_t *vu_times = tor_calloc(n_votes, sizeof(time_t));
+ int *votesec_list = tor_calloc(n_votes, sizeof(int));
+ int *distsec_list = tor_calloc(n_votes, sizeof(int));
int n_versioning_clients = 0, n_versioning_servers = 0;
smartlist_t *combined_client_versions = smartlist_new();
smartlist_t *combined_server_versions = smartlist_new();
@@ -1555,9 +1555,9 @@ networkstatus_compute_consensus(smartlist_t *votes,
smartlist_t *chosen_flags = smartlist_new();
smartlist_t *versions = smartlist_new();
smartlist_t *exitsummaries = smartlist_new();
- uint32_t *bandwidths_kb = tor_malloc(sizeof(uint32_t) *
+ uint32_t *bandwidths_kb = tor_calloc(sizeof(uint32_t),
smartlist_len(votes));
- uint32_t *measured_bws_kb = tor_malloc(sizeof(uint32_t) *
+ uint32_t *measured_bws_kb = tor_calloc(sizeof(uint32_t),
smartlist_len(votes));
int num_bandwidths;
int num_mbws;
@@ -1579,13 +1579,13 @@ networkstatus_compute_consensus(smartlist_t *votes,
memset(conflict, 0, sizeof(conflict));
memset(unknown, 0xff, sizeof(conflict));
- index = tor_malloc_zero(sizeof(int)*smartlist_len(votes));
- size = tor_malloc_zero(sizeof(int)*smartlist_len(votes));
- n_voter_flags = tor_malloc_zero(sizeof(int) * smartlist_len(votes));
- n_flag_voters = tor_malloc_zero(sizeof(int) * smartlist_len(flags));
- flag_map = tor_malloc_zero(sizeof(int*) * smartlist_len(votes));
- named_flag = tor_malloc_zero(sizeof(int) * smartlist_len(votes));
- unnamed_flag = tor_malloc_zero(sizeof(int) * smartlist_len(votes));
+ index = tor_calloc(sizeof(int), smartlist_len(votes));
+ size = tor_calloc(sizeof(int), smartlist_len(votes));
+ n_voter_flags = tor_calloc(sizeof(int), smartlist_len(votes));
+ n_flag_voters = tor_calloc(sizeof(int), smartlist_len(flags));
+ flag_map = tor_calloc(sizeof(int *), smartlist_len(votes));
+ named_flag = tor_calloc(sizeof(int), smartlist_len(votes));
+ unnamed_flag = tor_calloc(sizeof(int), smartlist_len(votes));
for (i = 0; i < smartlist_len(votes); ++i)
unnamed_flag[i] = named_flag[i] = -1;
chosen_named_idx = smartlist_string_pos(flags, "Named");
@@ -1597,8 +1597,8 @@ networkstatus_compute_consensus(smartlist_t *votes,
* that they're actually set before doing U64_LITERAL(1) << index with
* them.*/
SMARTLIST_FOREACH_BEGIN(votes, networkstatus_t *, v) {
- flag_map[v_sl_idx] = tor_malloc_zero(
- sizeof(int)*smartlist_len(v->known_flags));
+ flag_map[v_sl_idx] = tor_calloc(sizeof(int),
+ smartlist_len(v->known_flags));
if (smartlist_len(v->known_flags) > MAX_KNOWN_FLAGS_IN_VOTE) {
log_warn(LD_BUG, "Somehow, a vote has %d entries in known_flags",
smartlist_len(v->known_flags));
@@ -1678,7 +1678,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
);
/* Now go through all the votes */
- flag_counts = tor_malloc(sizeof(int) * smartlist_len(flags));
+ flag_counts = tor_calloc(sizeof(int), smartlist_len(flags));
while (1) {
vote_routerstatus_t *rs;
routerstatus_t rs_out;