init_group_property(&prop->group, prop, child);
list_head_init(&prop->group.list);
+ update_bounds(&prop->group);
}
return prop;
}
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;
freefn(t);
}
-void *tal_alloc_(const tal_t *ctx, size_t size, bool clear)
+void *tal_alloc_(const tal_t *ctx, size_t size, bool clear, const char *label)
{
struct tal_hdr *child, *parent = debug_tal(to_tal_hdr_or_null(ctx));
return NULL;
if (clear)
memset(from_tal_hdr(child), 0, size);
- child->prop = NULL;
+ child->prop = (void *)label;
if (!add_child(parent, child)) {
freefn(child);
return NULL;
/* 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;
name = (struct name *)p;
break;
}
- if (p != &null_parent.c.hdr && !in_bounds(p))
+ if (p != &null_parent.c.hdr && p != &null_parent.c.group.hdr
+ && !in_bounds(p))
return check_err(t, errorstr,
"has bad property pointer");