aboutsummaryrefslogtreecommitdiff
path: root/src/or/geoip.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-01-11 13:44:10 -0500
committerNick Mathewson <nickm@torproject.org>2012-01-16 15:02:51 -0500
commitedcc9981d8b8894d2ef4e0d617a20d7d99547817 (patch)
tree44476ecc42282d66930fb659d27fc9ad3c5a74b6 /src/or/geoip.c
parent9c6d913b9e1b84ffcefb2cbd9cfe6f7bd15fc9b3 (diff)
downloadtor-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/geoip.c')
-rw-r--r--src/or/geoip.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/or/geoip.c b/src/or/geoip.c
index 73194ae9c6..3e1ee5987f 100644
--- a/src/or/geoip.c
+++ b/src/or/geoip.c
@@ -856,9 +856,7 @@ geoip_get_client_history(geoip_client_action_t action)
/* Build the result. */
chunks = smartlist_create();
SMARTLIST_FOREACH(entries, c_hist_t *, ch, {
- char *buf=NULL;
- tor_asprintf(&buf, "%s=%u", ch->country, ch->total);
- smartlist_add(chunks, buf);
+ smartlist_add_asprintf(chunks, "%s=%u", ch->country, ch->total);
});
result = smartlist_join_strings(chunks, ",", 0, NULL);
done:
@@ -907,10 +905,8 @@ geoip_get_request_history(geoip_client_action_t action)
strings = smartlist_create();
SMARTLIST_FOREACH(entries, c_hist_t *, ent, {
- char *buf = NULL;
- tor_asprintf(&buf, "%s=%u", ent->country, ent->total);
- smartlist_add(strings, buf);
- });
+ smartlist_add_asprintf(strings, "%s=%u", ent->country, ent->total);
+ });
result = smartlist_join_strings(strings, ",", 0, NULL);
SMARTLIST_FOREACH(strings, char *, cp, tor_free(cp));
SMARTLIST_FOREACH(entries, c_hist_t *, ent, tor_free(ent));