summaryrefslogtreecommitdiff
path: root/lib/talloc/talloc.h
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2012-04-16 13:32:02 +0200
committerVolker Lendecke <vl@samba.org>2012-04-18 10:27:16 +0200
commit30ca3915e50a9d9f71a28b7779fce81f8b6453d5 (patch)
tree450a50d19038e7ec4c68f24473adae4a7c42e263 /lib/talloc/talloc.h
parent50689aee380b5eea75c0dbb8aedaca0b45bdd5ae (diff)
downloadsamba-30ca3915e50a9d9f71a28b7779fce81f8b6453d5.tar.gz
samba-30ca3915e50a9d9f71a28b7779fce81f8b6453d5.tar.bz2
samba-30ca3915e50a9d9f71a28b7779fce81f8b6453d5.zip
Talloc doc: talloc_asprintf_append_buffer()
Explains the difference between _append and _append_buffer.
Diffstat (limited to 'lib/talloc/talloc.h')
-rw-r--r--lib/talloc/talloc.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/talloc/talloc.h b/lib/talloc/talloc.h
index 244785b3a4..c1b5650266 100644
--- a/lib/talloc/talloc.h
+++ b/lib/talloc/talloc.h
@@ -1540,6 +1540,25 @@ char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3
/**
* @brief Append a formatted string to another string.
*
+ * This is a more efficient version of talloc_asprintf_append(). It determines
+ * the length of the destination string by the size of the talloc context.
+ *
+ * Use this very carefully as it produces a different result than
+ * talloc_asprintf_append() when a zero character is in the middle of the
+ * destination string.
+ *
+ * @code
+ * char *str_a = talloc_strdup(NULL, "hello world");
+ * char *str_b = talloc_strdup(NULL, "hello world");
+ * str_a[5] = str_b[5] = '\0'
+ *
+ * char *app = talloc_asprintf_append(str_a, "%s", ", hello");
+ * char *buf = talloc_strdup_append_buffer(str_b, "%s", ", hello");
+ *
+ * printf("%s\n", app); // hello, hello (app = "hello, hello")
+ * printf("%s\n", buf); // hello (buf = "hello\0world, hello")
+ * @endcode
+ *
* @param[in] s The string to append to
*
* @param[in] fmt The format string.
@@ -1547,6 +1566,9 @@ char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3
* @param[in] ... The parameters used to fill fmt.
*
* @return The formatted string, NULL on error.
+ *
+ * @see talloc_asprintf()
+ * @see talloc_asprintf_append()
*/
char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);