X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Faga%2Fbfs.c;h=b41136081f10027dcd6afe49ad743a39ecf9ac10;hb=578c4bfb22dd2df3c8133066b28397725b76734a;hp=01eb851c1a97cc2e1cf748b3c2e39a337e281e3c;hpb=f3160af8e033d56f02c8fb188557e42fcdffcf7b;p=ccan diff --git a/ccan/aga/bfs.c b/ccan/aga/bfs.c index 01eb851c..b4113608 100644 --- a/ccan/aga/bfs.c +++ b/ccan/aga/bfs.c @@ -12,25 +12,27 @@ * Breadth first search */ -static bool bfs_enqueue(struct aga_graph *g, struct lqueue *queue, +typedef LQUEUE(struct aga_node, u.bfs.next) bfs_queue; + +static bool bfs_enqueue(struct aga_graph *g, bfs_queue *queue, struct aga_node *n) { if (!aga_update_node(g, n)) return false; - lqueue_enqueue(queue, n, u.bfs.next); + lqueue_enqueue(queue, n); n->u.bfs.edge = aga_first_edge(g, n); return true; } -static struct aga_node *bfs_front(struct lqueue *queue) +static struct aga_node *bfs_front(bfs_queue *queue) { - return lqueue_front(queue, struct aga_node, u.bfs.next); + return lqueue_front(queue); } -static void bfs_dequeue(struct lqueue *queue) +static void bfs_dequeue(bfs_queue *queue) { - lqueue_dequeue(queue, struct aga_node, u.bfs.next); + (void) lqueue_dequeue(queue); } int aga_bfs_start(struct aga_graph *g) @@ -46,7 +48,7 @@ int aga_bfs_start(struct aga_graph *g) struct aga_node *aga_bfs_explore(struct aga_graph *g, struct aga_node *n) { - LQUEUE(queue); + bfs_queue queue = LQUEUE_INIT; if (!aga_check_state(g)) return NULL; @@ -57,7 +59,7 @@ struct aga_node *aga_bfs_explore(struct aga_graph *g, struct aga_node *n) if (bfs_enqueue(g, &queue, n)) return n; - lqueue_init_from_back(&queue, n, u.bfs.next); + lqueue_init_from_back(&queue, n); while ((n = bfs_front(&queue))) { const void *e = n->u.bfs.edge;