From 77a494dd551c67f2234c1a32f7739961987d8edc Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Sat, 3 Dec 2005 02:21:31 +0000 Subject: [PATCH] Expunge remaining places where we used "tree" to mean "associative array". svn:r5490 --- src/or/circuitlist.c | 20 +++++++++----------- src/or/connection_edge.c | 8 ++++---- src/or/dns.c | 6 +++--- src/or/main.c | 2 +- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c index 908ecc35e1..0793d11a5e 100644 --- a/src/or/circuitlist.c +++ b/src/or/circuitlist.c @@ -53,10 +53,10 @@ _orconn_circid_entry_hash(orconn_circid_circuit_map_t *a) return (((unsigned)a->circ_id)<<16) ^ (unsigned)(uintptr_t)(a->or_conn); } -static HT_HEAD(orconn_circid_tree, orconn_circid_circuit_map_t) orconn_circid_circuit_map = HT_INITIALIZER(); -HT_PROTOTYPE(orconn_circid_tree, orconn_circid_circuit_map_t, node, +static HT_HEAD(orconn_circid_map, orconn_circid_circuit_map_t) orconn_circid_circuit_map = HT_INITIALIZER(); +HT_PROTOTYPE(orconn_circid_map, orconn_circid_circuit_map_t, node, _orconn_circid_entry_hash, _orconn_circid_entries_eq); -HT_GENERATE(orconn_circid_tree, orconn_circid_circuit_map_t, node, +HT_GENERATE(orconn_circid_map, orconn_circid_circuit_map_t, node, _orconn_circid_entry_hash, _orconn_circid_entries_eq, 0.6, malloc, realloc, free); @@ -64,8 +64,6 @@ HT_GENERATE(orconn_circid_tree, orconn_circid_circuit_map_t, node, * used to improve performance when many cells arrive in a row from the * same circuit. */ -/* (We tried using splay trees, but round-robin turned out to make them - * suck.) */ orconn_circid_circuit_map_t *_last_circid_orconn_ent = NULL; /** Set the p_conn or n_conn field of a circuit circ, along @@ -108,7 +106,7 @@ circuit_set_circid_orconn(circuit_t *circ, uint16_t id, if (old_conn) { /* we may need to remove it from the conn-circid map */ search.circ_id = old_id; search.or_conn = old_conn; - found = HT_REMOVE(orconn_circid_tree, &orconn_circid_circuit_map, &search); + found = HT_REMOVE(orconn_circid_map, &orconn_circid_circuit_map, &search); if (found) { tor_free(found); } @@ -121,7 +119,7 @@ circuit_set_circid_orconn(circuit_t *circ, uint16_t id, /* now add the new one to the conn-circid map */ search.circ_id = id; search.or_conn = conn; - found = HT_FIND(orconn_circid_tree, &orconn_circid_circuit_map, &search); + found = HT_FIND(orconn_circid_map, &orconn_circid_circuit_map, &search); if (found) { found->circuit = circ; } else { @@ -129,7 +127,7 @@ circuit_set_circid_orconn(circuit_t *circ, uint16_t id, found->circ_id = id; found->or_conn = conn; found->circuit = circ; - HT_INSERT(orconn_circid_tree, &orconn_circid_circuit_map, found); + HT_INSERT(orconn_circid_map, &orconn_circid_circuit_map, found); } ++conn->n_circuits; } @@ -397,7 +395,7 @@ circuit_get_by_circid_orconn_impl(uint16_t circ_id, connection_t *conn) } else { search.circ_id = circ_id; search.or_conn = conn; - found = HT_FIND(orconn_circid_tree, &orconn_circid_circuit_map, &search); + found = HT_FIND(orconn_circid_map, &orconn_circid_circuit_map, &search); _last_circid_orconn_ent = found; } if (found && found->circuit) @@ -410,11 +408,11 @@ circuit_get_by_circid_orconn_impl(uint16_t circ_id, connection_t *conn) circuit_t *circ; for (circ=global_circuitlist;circ;circ = circ->next) { if (circ->p_conn == conn && circ->p_circ_id == circ_id) { - warn(LD_BUG, "circuit matches p_conn, but not in tree (Bug!)"); + warn(LD_BUG, "circuit matches p_conn, but not in hash table (Bug!)"); return circ; } if (circ->n_conn == conn && circ->n_circ_id == circ_id) { - warn(LD_BUG, "circuit matches n_conn, but not in tree (Bug!)"); + warn(LD_BUG, "circuit matches n_conn, but not in hash table (Bug!)"); return circ; } } diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index c66ec9c668..0764e255e3 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -424,8 +424,8 @@ connection_ap_detach_retriable(connection_t *conn, circuit_t *circ) } /** A client-side struct to remember requests to rewrite addresses - * to new addresses. These structs make up a tree, with addressmap - * below as its root. + * to new addresses. These structs are stored the hash table + * "addressmap" below. * * There are 5 ways to set an address mapping: * - A MapAddress command from the controller [permanent] @@ -455,10 +455,10 @@ typedef struct { char *hostname_address; } virtaddress_entry_t; -/** The tree of client-side address rewrite instructions. */ +/** A hash table to store client-side address rewrite instructions. */ static strmap_t *addressmap=NULL; /** - * Tree mapping addresses to which virtual address, if any, we + * Table mapping addresses to which virtual address, if any, we * assigned them to. * * We maintain the following invariant: if [A,B] is in diff --git a/src/or/dns.c b/src/or/dns.c index 1f7b728444..9a1fd3b5b4 100644 --- a/src/or/dns.c +++ b/src/or/dns.c @@ -80,7 +80,7 @@ static void send_resolved_cell(connection_t *conn, uint8_t answer_type); static HT_HEAD(cache_map, cached_resolve_t) cache_root; /** Function to compare hashed resolves on their addresses; used to - * implement splay trees. */ + * implement hash tables. */ static INLINE int cached_resolves_eq(cached_resolve_t *a, cached_resolve_t *b) { @@ -279,7 +279,7 @@ dns_resolve(connection_t *exitconn) /* lower-case exitconn->address, so it's in canonical form */ tor_strlower(exitconn->address); - /* now check the tree to see if 'address' is already there. */ + /* now check the hash table to see if 'address' is already there. */ strlcpy(search.address, exitconn->address, sizeof(search.address)); resolve = HT_FIND(cache_map, &cache_root, &search); if (resolve) { /* already there */ @@ -536,7 +536,7 @@ dns_purge_resolve(cached_resolve_t *resolve) newest_cached_resolve = tmp; } - /* remove resolve from the tree */ + /* remove resolve from the map */ HT_REMOVE(cache_map, &cache_root, resolve); tor_free(resolve); diff --git a/src/or/main.c b/src/or/main.c index d1be68ca3c..ccba96e991 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -1036,7 +1036,7 @@ do_main_loop(void) { int loop_result; - dns_init(); /* initialize dns resolve tree, spawn workers if needed */ + dns_init(); /* initialize dns resolve map, spawn workers if needed */ handle_signals(1);