]> git.meshlink.io Git - meshlink/commitdiff
Move edge_weight_tree to mesh->edges.
authorGuus Sliepen <guus@sliepen.org>
Mon, 21 Apr 2014 18:57:14 +0000 (20:57 +0200)
committerGuus Sliepen <guus@sliepen.org>
Mon, 21 Apr 2014 19:00:16 +0000 (21:00 +0200)
src/edge.c
src/edge.h
src/graph.c
src/net.c
src/net_packet.c

index 88847909c01b3fb9e31b19e5a08e1a444e293974..d3dbf78e90200c9c5994dfccf0adf9ab65f4701a 100644 (file)
 #include "splay_tree.h"
 #include "edge.h"
 #include "logger.h"
+#include "meshlink_internal.h"
 #include "netutl.h"
 #include "node.h"
 #include "utils.h"
 #include "xalloc.h"
 
-splay_tree_t *edge_weight_tree;
-
 static int edge_compare(const edge_t *a, const edge_t *b) {
        return strcmp(a->to->name, b->to->name);
 }
@@ -50,7 +49,7 @@ static int edge_weight_compare(const edge_t *a, const edge_t *b) {
 }
 
 void init_edges(void) {
-       edge_weight_tree = splay_alloc_tree((splay_compare_t) edge_weight_compare, NULL);
+       mesh->edges = splay_alloc_tree((splay_compare_t) edge_weight_compare, NULL);
 }
 
 splay_tree_t *new_edge_tree(void) {
@@ -62,7 +61,7 @@ void free_edge_tree(splay_tree_t *edge_tree) {
 }
 
 void exit_edges(void) {
-       splay_delete_tree(edge_weight_tree);
+       splay_delete_tree(mesh->edges);
 }
 
 /* Creation and deletion of connection elements */
@@ -78,7 +77,7 @@ void free_edge(edge_t *e) {
 }
 
 void edge_add(edge_t *e) {
-       splay_insert(edge_weight_tree, e);
+       splay_insert(mesh->edges, e);
        splay_insert(e->from->edge_tree, e);
 
        e->reverse = lookup_edge(e->to, e->from);
@@ -91,7 +90,7 @@ void edge_del(edge_t *e) {
        if(e->reverse)
                e->reverse->reverse = NULL;
 
-       splay_delete(edge_weight_tree, e);
+       splay_delete(mesh->edges, e);
        splay_delete(e->from->edge_tree, e);
 }
 
index 77f761dccea42df63a15faa5ac3d17cec68af170..75d4f94ec37df0e13c739c374e748447259dfe7d 100644 (file)
@@ -37,8 +37,6 @@ typedef struct edge_t {
        struct edge_t *reverse;                 /* edge in the opposite direction, if available */
 } edge_t;
 
-extern struct splay_tree_t *edge_weight_tree;          /* Tree with all known edges sorted on weight */
-
 extern void init_edges(void);
 extern void exit_edges(void);
 extern edge_t *new_edge(void) __attribute__ ((__malloc__));
index 43e526b044ce781976d403f4b50fee581a472d11..ce8fa6264ca2cafc61f5b06f286fa0a6899c0ce0 100644 (file)
@@ -76,7 +76,7 @@ static void mst_kruskal(void) {
 
        /* Starting point */
 
-       for splay_each(edge_t, e, edge_weight_tree) {
+       for splay_each(edge_t, e, mesh->edges) {
                if(e->from->status.reachable) {
                        e->from->status.visited = true;
                        break;
@@ -87,7 +87,7 @@ static void mst_kruskal(void) {
 
        bool skipped = false;
 
-       for splay_each(edge_t, e, edge_weight_tree) {
+       for splay_each(edge_t, e, mesh->edges) {
                if(!e->reverse || (e->from->status.visited == e->to->status.visited)) {
                        skipped = true;
                        continue;
@@ -106,7 +106,7 @@ static void mst_kruskal(void) {
 
                if(skipped) {
                        skipped = false;
-                       next = edge_weight_tree->head;
+                       next = mesh->edges->head;
                }
        }
 }
index 4cae25c1b15206403acf9c5a18d98337dcf5f65c..b8ea3cbd96af65b9a2ba4c18ac11c7f98efd7db2 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -64,7 +64,7 @@ void purge(void) {
 
        for splay_each(node_t, n, node_tree) {
                if(!n->status.reachable) {
-                       for splay_each(edge_t, e, edge_weight_tree)
+                       for splay_each(edge_t, e, mesh->edges)
                                if(e->to == n)
                                        return;
                }
index 7457b3bd76c1b9caa12d37d2879d34cf17ca9cdb..29f4fb8e59aebfcd900c99b5230db87335c2913e 100644 (file)
@@ -602,7 +602,7 @@ static node_t *try_harder(const sockaddr_t *from, const vpn_packet_t *pkt) {
        bool hard = false;
        static time_t last_hard_try = 0;
 
-       for splay_each(edge_t, e, edge_weight_tree) {
+       for splay_each(edge_t, e, mesh->edges) {
                if(!e->to->status.reachable || e->to == mesh->self)
                        continue;