children = add_child_property(parent, child);
if (!children)
return false;
- children->group.list.n.next = children->group.list.n.prev
- = &children->group.list.n;
+ list_head_init(&children->group.list);
/* Child links to itself. */
child->next = child;
/* Are we the only one? */
if (prev == t) {
+ struct prop_hdr *next = (*prop)->next;
struct children *c = group->parent_child;
/* Is this the group embedded in the child property? */
if (group == &c->group) {
} else {
/* Empty group, so free it. */
list_del_from(&c->group.list, &group->list.n);
- *prop = group->hdr.next;
freefn(group);
}
+ *prop = next;
return c->parent;
} else {
/* Move property to next node. */
tal_t *tal_parent(const tal_t *ctx)
{
struct group *group;
- struct tal_hdr *t = debug_tal(to_tal_hdr(ctx));
+ struct tal_hdr *t;
+
+ if (!ctx)
+ return NULL;
+
+ t = debug_tal(to_tal_hdr(ctx));
while (!(group = find_property(t, GROUP)))
t = t->next;