+static int talloc_darray_destructor(void *ptr);
+
+/*
+ * darray(T) *talloc_darray(const void *context);
+ *
+ * Create a new darray anchored in a talloc buffer.
+ * When this pointer is freed, the darray will be freed as well.
+ */
+static void *talloc_darray(const void *context)
+{
+ void *ret = talloc(context, darray(void));
+ darray_init(*(darray(void)*)ret);
+ talloc_set_destructor(ret, talloc_darray_destructor);
+ return ret;
+}
+
+static int talloc_darray_destructor(void *ptr)
+{
+ darray(void) *arr = ptr;
+ free(arr->item);
+ return 0;
+}
+