From: Guus Sliepen Date: Fri, 6 Sep 2002 10:23:52 +0000 (+0000) Subject: Remove global edge_tree. X-Git-Tag: release-1.0pre8~23 X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=fbf8a47879671541939cfdc6beb93b02b9eee303;p=tinc Remove global edge_tree. --- diff --git a/src/edge.c b/src/edge.c index a0f5535f..4a000e88 100644 --- a/src/edge.c +++ b/src/edge.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: edge.c,v 1.1.2.12 2002/09/04 13:48:51 guus Exp $ + $Id: edge.c,v 1.1.2.13 2002/09/06 10:23:52 guus Exp $ */ #include "config.h" @@ -41,32 +41,13 @@ #include "xalloc.h" #include "system.h" -avl_tree_t *edge_tree; /* Tree with all known edges (replaces active_tree) */ avl_tree_t *edge_weight_tree; /* Tree with all edges, sorted on weight */ int edge_compare(edge_t *a, edge_t *b) { - int result; - - result = strcmp(a->from->name, b->from->name); - - if(result) - return result; - else - return strcmp(a->to->name, b->to->name); -} - -/* Evil edge_compare() from a parallel universe ;) - -int edge_compare(edge_t *a, edge_t *b) -{ - int result; - - return (result = strcmp(a->from->name, b->from->name)) || (result = strcmp(a->to->name, b->to->name)), result; + return strcmp(a->to->name, b->to->name); } -*/ - int edge_weight_compare(edge_t *a, edge_t *b) { int result; @@ -82,7 +63,6 @@ int edge_weight_compare(edge_t *a, edge_t *b) void init_edges(void) { cp - edge_tree = avl_alloc_tree((avl_compare_t)edge_compare, NULL); edge_weight_tree = avl_alloc_tree((avl_compare_t)edge_weight_compare, NULL); cp } @@ -104,7 +84,7 @@ cp void exit_edges(void) { cp - avl_delete_tree(edge_tree); + avl_delete_tree(edge_weight_tree); cp } @@ -129,7 +109,6 @@ cp void edge_add(edge_t *e) { cp - avl_insert(edge_tree, e); avl_insert(edge_weight_tree, e); avl_insert(e->from->edge_tree, e); cp @@ -145,7 +124,6 @@ cp if(e->reverse) e->reverse->reverse = NULL; cp - avl_delete(edge_tree, e); avl_delete(edge_weight_tree, e); avl_delete(e->from->edge_tree, e); cp @@ -158,25 +136,30 @@ cp v.from = from; v.to = to; - return avl_search(edge_tree, &v); + return avl_search(from->edge_tree, &v); } void dump_edges(void) { - avl_node_t *node; + avl_node_t *node, *node2; + node_t *n; edge_t *e; char *address; cp syslog(LOG_DEBUG, _("Edges:")); - for(node = edge_tree->head; node; node = node->next) + for(node = node_tree->head; node; node = node->next) { - e = (edge_t *)node->data; - address = sockaddr2hostname(&e->address); - syslog(LOG_DEBUG, _(" %s to %s at %s options %lx weight %d"), - e->from->name, e->to->name, address, - e->options, e->weight); - free(address); + n = (node_t *)node->data; + for(node2 = n->edge_tree->head; node2; node2 = node2->next) + { + e = (edge_t *)node2->data; + address = sockaddr2hostname(&e->address); + syslog(LOG_DEBUG, _(" %s to %s at %s options %lx weight %d"), + e->from->name, e->to->name, address, + e->options, e->weight); + free(address); + } } syslog(LOG_DEBUG, _("End of edges.")); diff --git a/src/edge.h b/src/edge.h index e3735e63..9ddb7564 100644 --- a/src/edge.h +++ b/src/edge.h @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: edge.h,v 1.1.2.9 2002/09/04 13:48:51 guus Exp $ + $Id: edge.h,v 1.1.2.10 2002/09/06 10:23:52 guus Exp $ */ #ifndef __TINC_EDGE_H__ @@ -41,7 +41,6 @@ typedef struct edge_t { struct edge_t *reverse; /* edge in the opposite direction, if available */ } edge_t; -extern avl_tree_t *edge_tree; /* Tree with all known edges */ extern avl_tree_t *edge_weight_tree; /* Tree with all known edges sorted on weight */ extern void init_edges(void); diff --git a/src/net_packet.c b/src/net_packet.c index 8419d6a0..7dd9a21a 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: net_packet.c,v 1.1.2.19 2002/09/04 13:48:52 guus Exp $ + $Id: net_packet.c,v 1.1.2.20 2002/09/06 10:23:52 guus Exp $ */ #include "config.h" @@ -429,4 +429,3 @@ cp receive_udppacket(n, &pkt); cp } -