aboutsummaryrefslogtreecommitdiff
path: root/src/or/geoip.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-07-16 14:04:36 -0400
committerNick Mathewson <nickm@torproject.org>2013-08-15 12:03:36 -0400
commit9d8ffa91ceb3dd57b9ff1170ebe200db25403391 (patch)
tree52fbe3675aaf900112e88b56284e8a7d0b732c81 /src/or/geoip.c
parent34d02484c06f26653563176e4b5db2829ae4bc23 (diff)
downloadtor-9d8ffa91ceb3dd57b9ff1170ebe200db25403391.tar
tor-9d8ffa91ceb3dd57b9ff1170ebe200db25403391.tar.gz
Add a clientmap_entry_free().
Remove a nedless strdup/free pair.
Diffstat (limited to 'src/or/geoip.c')
-rw-r--r--src/or/geoip.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/or/geoip.c b/src/or/geoip.c
index 21dceed3d..dc4730c81 100644
--- a/src/or/geoip.c
+++ b/src/or/geoip.c
@@ -507,6 +507,17 @@ HT_PROTOTYPE(clientmap, clientmap_entry_t, node, clientmap_entry_hash,
HT_GENERATE(clientmap, clientmap_entry_t, node, clientmap_entry_hash,
clientmap_entries_eq, 0.6, malloc, realloc, free);
+/** Free all storage held by <b>ent</b>. */
+static void
+clientmap_entry_free(clientmap_entry_t *ent)
+{
+ if (!ent)
+ return;
+
+ tor_free(ent->transport_name);
+ tor_free(ent);
+}
+
/** Clear history of connecting clients used by entry and bridge stats. */
static void
client_history_clear(void)
@@ -517,7 +528,7 @@ client_history_clear(void)
if ((*ent)->action == GEOIP_CLIENT_CONNECT) {
this = *ent;
next = HT_NEXT_RMV(clientmap, &client_history, ent);
- tor_free(this);
+ clientmap_entry_free(this);
} else {
next = HT_NEXT(clientmap, &client_history, ent);
}
@@ -554,10 +565,8 @@ geoip_note_client_seen(geoip_client_action_t action,
tor_addr_copy(&lookup.addr, addr);
lookup.action = (int)action;
- if (transport_name)
- lookup.transport_name = tor_strdup(transport_name);
+ lookup.transport_name = (char*) transport_name;
ent = HT_FIND(clientmap, &client_history, &lookup);
- tor_free(lookup.transport_name);
if (! ent) {
ent = tor_malloc_zero(sizeof(clientmap_entry_t));
@@ -590,8 +599,7 @@ remove_old_client_helper_(struct clientmap_entry_t *ent, void *_cutoff)
{
time_t cutoff = *(time_t*)_cutoff / 60;
if (ent->last_seen_in_minutes < cutoff) {
- tor_free(ent->transport_name);
- tor_free(ent);
+ clientmap_entry_free(ent);
return 1;
} else {
return 0;
@@ -1162,7 +1170,7 @@ geoip_reset_dirreq_stats(time_t now)
if ((*ent)->action == GEOIP_CLIENT_NETWORKSTATUS) {
this = *ent;
next = HT_NEXT_RMV(clientmap, &client_history, ent);
- tor_free(this);
+ clientmap_entry_free(this);
} else {
next = HT_NEXT(clientmap, &client_history, ent);
}
@@ -1656,8 +1664,7 @@ geoip_free_all(void)
for (ent = HT_START(clientmap, &client_history); ent != NULL; ent = next) {
this = *ent;
next = HT_NEXT_RMV(clientmap, &client_history, ent);
- tor_free(this->transport_name);
- tor_free(this);
+ clientmap_entry_free(this);
}
HT_CLEAR(clientmap, &client_history);
}