]> git.ozlabs.org Git - ccan/blob - ccan/tal/str/test/helper.h
tal/str: use tal/talloc backend #ifdef TAL_USE_TALLOC.
[ccan] / ccan / tal / str / test / helper.h
1 /* tal/talloc can't implement tal_first/tal_next. */
2 #ifdef TAL_USE_TALLOC
3 static inline bool no_children(const void *ctx)
4 {
5         return talloc_total_blocks(ctx) == 1;
6 }
7
8 static inline bool single_child(const void *ctx, const void *child)
9 {
10         return talloc_total_blocks(ctx) == 2 && tal_parent(child) == ctx;
11 }
12 #else
13 static inline bool no_children(const void *ctx)
14 {
15         return !tal_first(ctx);
16 }
17
18 static inline bool single_child(const void *ctx, const void *child)
19 {
20         return tal_first(ctx) == child && !tal_next(ctx, child);
21 }
22 #endif