summaryrefslogtreecommitdiff
path: root/lib/talloc/talloc.h
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2013-09-06 15:15:32 -0700
committerVolker Lendecke <vl@samba.org>2013-09-08 11:34:06 +0200
commite82320e5197bcdd0330bc829c0963ad09854a36c (patch)
tree2104b05c3bb677d4dd8036101992f923a6e05c4f /lib/talloc/talloc.h
parent20ad6d7aa3dc5e7db4d886202f757ac1f68287d4 (diff)
downloadsamba-e82320e5197bcdd0330bc829c0963ad09854a36c.tar.gz
samba-e82320e5197bcdd0330bc829c0963ad09854a36c.tar.bz2
samba-e82320e5197bcdd0330bc829c0963ad09854a36c.zip
talloc: Add talloc_pooled_object
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/talloc/talloc.h')
-rw-r--r--lib/talloc/talloc.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/talloc/talloc.h b/lib/talloc/talloc.h
index aa9864b436..1b59390e33 100644
--- a/lib/talloc/talloc.h
+++ b/lib/talloc/talloc.h
@@ -847,6 +847,43 @@ void *talloc_find_parent_bytype(const void *ptr, #type);
*/
void *talloc_pool(const void *context, size_t size);
+#ifdef DOXYGEN
+/**
+ * @brief Allocate a talloc object as/with an additional pool.
+ *
+ * This is like talloc_pool(), but's it's more flexible
+ * and allows an object to be a pool for its children.
+ *
+ * @param[in] ctx The talloc context to hang the result off.
+ *
+ * @param[in] type The type that we want to allocate.
+ *
+ * @param[in] num_subobjects The expected number of subobjects, which will
+ * be allocated within the pool. This allocates
+ * space for talloc_chunk headers.
+ *
+ * @param[in] total_subobjects_size The size that all subobjects can use in total.
+ *
+ *
+ * @return The allocated talloc object, NULL on error.
+ */
+void *talloc_pooled_object(const void *ctx, #type,
+ unsigned num_subobjects,
+ size_t total_subobjects_size);
+#else
+#define talloc_pooled_object(_ctx, _type, \
+ _num_subobjects, \
+ _total_subobjects_size) \
+ (_type *)_talloc_pooled_object((_ctx), sizeof(_type), #_type, \
+ (_num_subobjects), \
+ (_total_subobjects_size))
+void *_talloc_pooled_object(const void *ctx,
+ size_t type_size,
+ const char *type_name,
+ unsigned num_subobjects,
+ size_t total_subobjects_size);
+#endif
+
/**
* @brief Free a talloc chunk and NULL out the pointer.
*