X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftal%2Ftal.c;h=df4020ea07e4997b6888d9418cf521fa74437e6a;hp=1eaa5749476aa3abd23992c16167b031c47175f6;hb=77aa87f08799dafb2f4db6e967f0a3996e5ba883;hpb=d6bee61681cf3976c9c0e47e4d73b8ce18f9d7ce diff --git a/ccan/tal/tal.c b/ccan/tal/tal.c index 1eaa5749..df4020ea 100644 --- a/ccan/tal/tal.c +++ b/ccan/tal/tal.c @@ -630,31 +630,16 @@ tal_t *tal_first(const tal_t *root) return from_tal_hdr(c); } -tal_t *tal_next(const tal_t *root, const tal_t *prev) +tal_t *tal_next(const tal_t *prev) { - struct tal_hdr *c, *t = debug_tal(to_tal_hdr(prev)), *top; + struct tal_hdr *next, *prevhdr = debug_tal(to_tal_hdr(prev)); + struct list_head *head; - /* Children? */ - c = first_child(t); - if (c) - return from_tal_hdr(c); - - top = to_tal_hdr_or_null(root); - do { - struct tal_hdr *next; - struct list_node *end; - - end = &ignore_destroying_bit(t->parent_child)->children.n; - - next = list_entry(t->list.next, struct tal_hdr, list); - if (&next->list != end) - return from_tal_hdr(next); - - /* OK, go back to parent. */ - t = ignore_destroying_bit(t->parent_child)->parent; - } while (t != top); - - return NULL; + head = &ignore_destroying_bit(prevhdr->parent_child)->children; + next = list_next(head, prevhdr, list); + if (!next) + return NULL; + return from_tal_hdr(next); } tal_t *tal_parent(const tal_t *ctx) @@ -921,7 +906,6 @@ static bool check_node(struct children *parent_child, if (name) return check_err(t, errorstr, "has extra literal"); - name = (struct name *)p; break; } if (!in_bounds(p))