diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-01-11 13:44:10 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-01-16 15:02:51 -0500 |
commit | edcc9981d8b8894d2ef4e0d617a20d7d99547817 (patch) | |
tree | 44476ecc42282d66930fb659d27fc9ad3c5a74b6 /src/or/circuitbuild.c | |
parent | 9c6d913b9e1b84ffcefb2cbd9cfe6f7bd15fc9b3 (diff) | |
download | tor-edcc9981d8b8894d2ef4e0d617a20d7d99547817.tar.gz tor-edcc9981d8b8894d2ef4e0d617a20d7d99547817.zip |
Try to use smartlist_add_asprintf consistently
(To ensure correctness, in every case, make sure that the temporary
variable is deleted, renamed, or lowered in scope, so we can't have
any bugs related to accidentally relying on the no-longer-filled
variable.)
Diffstat (limited to 'src/or/circuitbuild.c')
-rw-r--r-- | src/or/circuitbuild.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index a9e5d22943..216c926585 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -1545,15 +1545,13 @@ circuit_list_path_impl(origin_circuit_t *circ, int verbose, int verbose_names) if (verbose) { const char *nickname = build_state_get_exit_nickname(circ->build_state); - char *cp; - tor_asprintf(&cp, "%s%s circ (length %d%s%s):", + smartlist_add_asprintf(elements, "%s%s circ (length %d%s%s):", circ->build_state->is_internal ? "internal" : "exit", circ->build_state->need_uptime ? " (high-uptime)" : "", circ->build_state->desired_path_len, circ->_base.state == CIRCUIT_STATE_OPEN ? "" : ", last hop ", circ->_base.state == CIRCUIT_STATE_OPEN ? "" : (nickname?nickname:"*unnamed*")); - smartlist_add(elements, cp); } hop = circ->cpath; @@ -3599,19 +3597,17 @@ log_entry_guards(int severity) SMARTLIST_FOREACH_BEGIN(entry_guards, entry_guard_t *, e) { const char *msg = NULL; - char *cp; if (entry_is_live(e, 0, 1, 0, &msg)) - tor_asprintf(&cp, "%s [%s] (up %s)", + smartlist_add_asprintf(elements, "%s [%s] (up %s)", e->nickname, hex_str(e->identity, DIGEST_LEN), e->made_contact ? "made-contact" : "never-contacted"); else - tor_asprintf(&cp, "%s [%s] (%s, %s)", + smartlist_add_asprintf(elements, "%s [%s] (%s, %s)", e->nickname, hex_str(e->identity, DIGEST_LEN), msg, e->made_contact ? "made-contact" : "never-contacted"); - smartlist_add(elements, cp); } SMARTLIST_FOREACH_END(e); |