]> git.ozlabs.org Git - ccan/blobdiff - ccan/tal/str/str.h
tal/str: use tal/talloc backend #ifdef TAL_USE_TALLOC.
[ccan] / ccan / tal / str / str.h
index 4a6c474a4428a3e79998d1168b09e8c28d2f57a9..0fe542cf235eeb9c08119f0de14ced6f6050a0ea 100644 (file)
@@ -1,8 +1,11 @@
 /* Licensed under BSD-MIT - see LICENSE file for details */
 #ifndef CCAN_STR_TAL_H
 #define CCAN_STR_TAL_H
+#ifdef TAL_USE_TALLOC
+#include <ccan/tal/talloc/talloc.h>
+#else
 #include <ccan/tal/tal.h>
-#include <ccan/tal/tal.h>
+#endif
 #include <string.h>
 #include <stdbool.h>
 
@@ -39,6 +42,25 @@ char *tal_fmt(const tal_t *ctx, const char *fmt, ...) PRINTF_FMT(2,3);
 char *tal_vfmt(const tal_t *ctx, const char *fmt, va_list ap)
        PRINTF_FMT(2,0);
 
+/**
+ * tal_append_fmt - append a formatted string to a talloc string.
+ * @baseptr: a pointer to the tal string to be appended to.
+ * @fmt: the printf-style format (can be take()).
+ *
+ * Returns false on allocation failure.
+ */
+bool tal_append_fmt(char **baseptr, const char *fmt, ...) PRINTF_FMT(2,3);
+
+/**
+ * tal_append_vfmt - append a formatted string to a talloc string (va_list)
+ * @baseptr: a pointer to the tal string to be appended to.
+ * @fmt: the printf-style format (can be take()).
+ * @va: the va_list containing the format args.
+ *
+ * Returns false on allocation failure.
+ */
+bool tal_append_vfmt(char **baseptr, const char *fmt, va_list ap);
+
 /**
  * tal_strcat - join two strings together
  * @ctx: NULL, or tal allocated object to be parent.