]> git.ozlabs.org Git - ccan/blobdiff - ccan/tal/tal.h
base64: Remove an invalid assertion
[ccan] / ccan / tal / tal.h
index 0b050759f74ed97829661de5dc2488af74264fe9..f360a9611a8730838b6af1a9b23a2381b3bbc294 100644 (file)
@@ -256,7 +256,7 @@ const char *tal_name(const tal_t *ptr);
  * tal_count - get the count of objects in a tal_arr.
  * @ptr: The tal allocated object array.
  *
- * Returns 0 if @ptr has no length property, but we aware that that is
+ * Returns 0 if @ptr has no length property, but be aware that that is
  * also a valid size!
  */
 size_t tal_count(const tal_t *ptr);
@@ -289,14 +289,25 @@ tal_t *tal_next(const tal_t *root, const tal_t *prev);
 tal_t *tal_parent(const tal_t *ctx);
 
 /**
- * tal_dup - duplicate an array.
+ * tal_dup - duplicate an object.
+ * @ctx: The tal allocated object to be parent of the result (may be NULL).
+ * @type: the type (should match type of @p!)
+ * @p: the object to copy (or reparented if take())
+ */
+#define tal_dup(ctx, type, p)                  \
+       ((type *)tal_dup_((ctx), tal_typechk_(p, type *),       \
+                         sizeof(type), 1, 0,                   \
+                         false, TAL_LABEL(type, "")))
+
+/**
+ * tal_dup_arr - duplicate an array.
  * @ctx: The tal allocated object to be parent of the result (may be NULL).
  * @type: the type (should match type of @p!)
  * @p: the array to copy (or resized & reparented if take())
  * @n: the number of sizeof(type) entries to copy.
  * @extra: the number of extra sizeof(type) entries to allocate.
  */
-#define tal_dup(ctx, type, p, n, extra)                                \
+#define tal_dup_arr(ctx, type, p, n, extra)                    \
        ((type *)tal_dup_((ctx), tal_typechk_(p, type *),       \
                          sizeof(type), (n), (extra),           \
                          true, TAL_LABEL(type, "[]")))
@@ -355,13 +366,16 @@ void tal_cleanup(void);
 
 
 /**
- * tal_check - set the allocation or error functions to use
+ * tal_check - sanity check a tal context and its children.
  * @ctx: a tal context, or NULL.
  * @errorstr: a string to prepend calls to error_fn, or NULL.
  *
  * This sanity-checks a tal tree (unless NDEBUG is defined, in which case
  * it simply returns true).  If errorstr is not null, error_fn is called
  * when a problem is found, otherwise it is not.
+ *
+ * See also:
+ *     tal_set_backend()
  */
 bool tal_check(const tal_t *ctx, const char *errorstr);