summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal/graph.c
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2017-03-25 18:48:30 +0100
committerSander Vrijders <[email protected]>2017-03-28 10:24:54 +0200
commitc0bfc1752df3530570a24c930220b94a4e3afabb (patch)
tree43abd2084831d5a36c88a8ad93b3dec3e48127cd /src/ipcpd/normal/graph.c
parentd3393da62009e49b5724f8ff3d901c244ab8d557 (diff)
downloadouroboros-c0bfc1752df3530570a24c930220b94a4e3afabb.tar.gz
ouroboros-c0bfc1752df3530570a24c930220b94a4e3afabb.zip
lib, ipcpd: Fix bugs in ro sets
This fixes several bugs in the ro sets, rib. And it fixes several bugs in the graph and routing component of the normal IPCP.
Diffstat (limited to 'src/ipcpd/normal/graph.c')
-rw-r--r--src/ipcpd/normal/graph.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/ipcpd/normal/graph.c b/src/ipcpd/normal/graph.c
index b3e105e3..272576bb 100644
--- a/src/ipcpd/normal/graph.c
+++ b/src/ipcpd/normal/graph.c
@@ -106,15 +106,15 @@ static void del_edge(struct edge * edge)
free(edge);
}
-static int add_vertex(struct graph * graph,
- uint64_t addr)
+static struct vertex * add_vertex(struct graph * graph,
+ uint64_t addr)
{
struct vertex * vertex;
struct list_head * p;
vertex = malloc(sizeof(*vertex));
if (vertex == NULL)
- return -1;
+ return NULL;
list_head_init(&vertex->next);
list_head_init(&vertex->edges);
@@ -130,7 +130,7 @@ static int add_vertex(struct graph * graph,
graph->nr_vertices++;
- return 0;
+ return vertex;
}
static void del_vertex(struct graph * graph,
@@ -206,7 +206,8 @@ int graph_add_edge(struct graph * graph,
v = find_vertex_by_addr(graph, s_addr);
if (v == NULL) {
- if (add_vertex(graph, s_addr)) {
+ v = add_vertex(graph, s_addr);
+ if (v == NULL) {
pthread_mutex_unlock(&graph->lock);
return -ENOMEM;
}
@@ -221,7 +222,8 @@ int graph_add_edge(struct graph * graph,
nb = find_vertex_by_addr(graph, d_addr);
if (nb == NULL) {
- if (add_vertex(graph, d_addr)) {
+ nb = add_vertex(graph, d_addr);
+ if (nb == NULL) {
pthread_mutex_unlock(&graph->lock);
return -ENOMEM;
}