From 6b694061a5f84ab19eb4db46d2463d673941da62 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 8 Nov 2010 20:44:06 +1030 Subject: [PATCH] talloc: define TALLOC_CTX I'm not a fan of the SHOUTING, but it's upstream. --- ccan/talloc/talloc.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ccan/talloc/talloc.h b/ccan/talloc/talloc.h index e65588cd..58b406e5 100644 --- a/ccan/talloc/talloc.h +++ b/ccan/talloc/talloc.h @@ -78,6 +78,29 @@ */ #define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) +/** + * TALLOC_CTX - indicate that a pointer is used as a talloc parent. + * + * As talloc is a hierarchial memory allocator, every talloc chunk is a + * potential parent to other talloc chunks. So defining a separate type for a + * talloc chunk is not strictly necessary. TALLOC_CTX is defined nevertheless, + * as it provides an indicator for function arguments. + * + * Example: + * struct foo { + * int val; + * }; + * + * static struct foo *foo_new(TALLOC_CTX *mem_ctx) + * { + * struct foo *foo = talloc(mem_ctx, struct foo); + * if (foo) + * foo->val = 0; + * return foo; + * } + */ +typedef void TALLOC_CTX; + /** * talloc_set - allocate dynamic memory for a type, into a pointer * @ptr: pointer to the pointer to assign. -- 2.39.2