summaryrefslogtreecommitdiff
path: root/ccan/tal/str/test/helper.h
blob: 5f0b68f5dca769ad33c03c6e2c6c6bde2ba2c3f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* tal/talloc can't implement tal_first/tal_next. */
#ifdef TAL_USE_TALLOC
static inline bool no_children(const void *ctx)
{
	return talloc_total_blocks(ctx) == 1;
}

static inline bool single_child(const void *ctx, const void *child)
{
	return talloc_total_blocks(ctx) == 2 && tal_parent(child) == ctx;
}
#else
static inline bool no_children(const void *ctx)
{
	return !tal_first(ctx);
}

static inline bool single_child(const void *ctx, const void *child)
{
	return tal_first(ctx) == child && !tal_next(child) && !tal_first(child);
}
#endif