]> git.ozlabs.org Git - ccan/blobdiff - ccan/tal/str/_info
tal/str: always create strings which have tal_count() == strlen() + 1.
[ccan] / ccan / tal / str / _info
index f95fc10eb8d35426ab7ebb384759413a01340544..9b9c70b6be7f1198e684e23dc0bf892f41fbb04f 100644 (file)
@@ -1,17 +1,19 @@
+#include "config.h"
 #include <stdio.h>
 #include <string.h>
-#include "config.h"
 
 /**
  * tal/str - string helper routines which use tal
  *
  * This is a grab bag of functions for string operations, designed to enhance
  * the standard string.h; these are separated from the non-tal-needing
- * string utilities in "str.h".
+ * string utilities in "str.h".  Each string created by this library
+ * will have tal_count() equal to strlen() + 1 (assuming you didn't create
+ * a string containing a NUL, such as using tal_fmt("%c", 0)).
  *
  * Example:
  *     #include <ccan/tal/str/str.h>
- *     #include <ccan/grab_file/grab_file.h>
+ *     #include <ccan/tal/grab_file/grab_file.h>
  *     #include <err.h>
  *
  *     // Dumb demo program to double-linespace a file.
  *             char *textfile;
  *             char **lines;
  *
+ *             if (argc > 2)
+ *                     errx(1, "Takes 0 or 1 arguments");
  *             // Grab lines in file.
- *             textfile = grab_file(NULL, argv[1], NULL);
+ *             textfile = grab_file(NULL, argv[1]);
  *             if (!textfile)
  *                     err(1, "Failed reading %s", argv[1]);
  *             lines = tal_strsplit(textfile, textfile, "\n", STR_EMPTY_OK);
@@ -44,7 +48,11 @@ int main(int argc, char *argv[])
 
        if (strcmp(argv[1], "depends") == 0) {
                printf("ccan/str\n");
+#ifdef TAL_USE_TALLOC
+               printf("ccan/tal/talloc\n");
+#else
                printf("ccan/tal\n");
+#endif
                printf("ccan/take\n");
                return 0;
        }