aboutsummaryrefslogtreecommitdiff
path: root/src/or/circuitbuild.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2010-10-15 14:02:55 -0400
committerNick Mathewson <nickm@torproject.org>2010-10-15 14:02:55 -0400
commit2c51cd2b109fce903aeef2e9d405013f12875bf8 (patch)
treeb8133c14a4a4d1e2c2ebb02f71fd062d43f608a0 /src/or/circuitbuild.c
parent96ab83d3b64a6e81f4e3f1c18598c942efea046c (diff)
downloadtor-2c51cd2b109fce903aeef2e9d405013f12875bf8.tar.gz
tor-2c51cd2b109fce903aeef2e9d405013f12875bf8.zip
Make the predicted ports logic a little simpler.
Mainly, this comes from turning two lists that needed to be kept in synch into a single list of structs. This should save a little RAM, and make the code simpler.
Diffstat (limited to 'src/or/circuitbuild.c')
-rw-r--r--src/or/circuitbuild.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index f8a198bb71..fc1f403157 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -2419,24 +2419,12 @@ new_route_len(uint8_t purpose, extend_info_t *exit,
return routelen;
}
-/** Fetch the list of predicted ports, dup it into a smartlist of
- * uint16_t's, remove the ones that are already handled by an
- * existing circuit, and return it.
- */
+/** Return a newly allocated list of uint16_t * for each predicted port not
+ * handled by a current circuit. */
static smartlist_t *
circuit_get_unhandled_ports(time_t now)
{
- smartlist_t *source = rep_hist_get_predicted_ports(now);
- smartlist_t *dest = smartlist_create();
- uint16_t *tmp;
- int i;
-
- for (i = 0; i < smartlist_len(source); ++i) {
- tmp = tor_malloc(sizeof(uint16_t));
- memcpy(tmp, smartlist_get(source, i), sizeof(uint16_t));
- smartlist_add(dest, tmp);
- }
-
+ smartlist_t *dest = rep_hist_get_predicted_ports(now);
circuit_remove_handled_ports(dest);
return dest;
}