]> git.ozlabs.org Git - ccan/commitdiff
Fix examples (they all compile now), and init parent list in list
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 13 Nov 2008 11:54:08 +0000 (22:24 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 13 Nov 2008 11:54:08 +0000 (22:24 +1030)
example.

ccan/alignof/_info.c
ccan/alloc/_info.c
ccan/build_assert/_info.c
ccan/container_of/_info.c
ccan/grab_file/_info.c
ccan/list/_info.c
ccan/noerr/_info.c
ccan/str/_info.c
ccan/str_talloc/_info.c
ccan/talloc/_info.c
ccan/tap/_info.c

index 3b73f655e2a9aa6910c89990e2d07525bcbf3c64..e647afbfeebb799a1f56c1be172da32e9a9ae133 100644 (file)
@@ -16,7 +16,8 @@
  *
  * Example:
  *     #include <stdio.h>
  *
  * Example:
  *     #include <stdio.h>
- *     #include "alignof/alignof.h"
+ *     #include <stdlib.h>
+ *     #include <ccan/alignof/alignof.h>
  *
  *     int main(int argc, char *argv[])
  *     {
  *
  *     int main(int argc, char *argv[])
  *     {
index 61c00464470bd2f8ebae40c18cb59048a34de8c4..9b00284f9e878c387c637e0bd4ea6d2092a9329e 100644 (file)
  *     #include <unistd.h>
  *     #include <sys/types.h>
  *     #include <err.h>
  *     #include <unistd.h>
  *     #include <sys/types.h>
  *     #include <err.h>
- *     #include "alloc/alloc.h"
+ *     #include <sys/stat.h>
+ *     #include <fcntl.h>
+ *     #include <string.h>
+ *     #include <ccan/alloc/alloc.h>
  *
  *     static void usage(const char *name)
  *     {
  *             errx(1, "Usage: %s --create <mapfile>\n"
  *                  " %s --check <mapfile>\n"
  *                  " %s --alloc <mapfile>\n"
  *
  *     static void usage(const char *name)
  *     {
  *             errx(1, "Usage: %s --create <mapfile>\n"
  *                  " %s --check <mapfile>\n"
  *                  " %s --alloc <mapfile>\n"
- *                  " %s --free=<offset> <mapfile>\n", name, name, name);
+ *                  " %s --free=<offset> <mapfile>\n", name, name, name, name);
  *     }
  *
  *     // Create a memory mapped file, and allocate from within it
  *     }
  *
  *     // Create a memory mapped file, and allocate from within it
index b61aeee0e41f00a244c48f5f9b58464702d6defd..d2fe3d9c80fc240daf4cef1e3b8b9113e4a152df 100644 (file)
  * you would catch such changes in your code like so:
  *
  * Example:
  * you would catch such changes in your code like so:
  *
  * Example:
+ *     #include <stddef.h>
+ *     #include <ccan/build_assert/build_assert.h>
+ *
+ *     struct foo {
+ *             char string[5];
+ *             int x;
+ *     };
+ *
  *     char *foo_string(struct foo *foo)
  *     {
  *             // This trick requires that the string be first in the structure
  *     char *foo_string(struct foo *foo)
  *     {
  *             // This trick requires that the string be first in the structure
index 194fcabaf4c07c20e5004633f1fb9d1ec311e57b..4c25c296036d510a84f2df79c44736004e2200f7 100644 (file)
  * callback.
  *
  * Example:
  * callback.
  *
  * Example:
- *     struct info
- *     {
+ *     #include <stdio.h>
+ *     #include <ccan/container_of/container_of.h>
+ *
+ *     struct timer {
+ *             void *members;
+ *     };
+ *
+ *     struct info {
  *             int my_stuff;
  *             struct timer timer;
  *     };
  *             int my_stuff;
  *             struct timer timer;
  *     };
@@ -31,7 +37,9 @@
  *             struct info info = { .my_stuff = 1 };
  *
  *             register_timer(&info.timer);
  *             struct info info = { .my_stuff = 1 };
  *
  *             register_timer(&info.timer);
- *             ...
+ *             // ...
+ *             return 0;
+ *     }
  *
  * Licence: LGPL (2 or any later version)
  */
  *
  * Licence: LGPL (2 or any later version)
  */
index 4aac31aebbd7b343b3e48527bcd5a4baf459b247..9a0249f1587616cd1144756023aaba0559756312 100644 (file)
@@ -8,10 +8,11 @@
  * This contains simple functions for getting the contents of a file.
  *
  * Example:
  * This contains simple functions for getting the contents of a file.
  *
  * Example:
- *     #include "grab_file/grab_file.h"
  *     #include <err.h>
  *     #include <stdio.h>
  *     #include <string.h>
  *     #include <err.h>
  *     #include <stdio.h>
  *     #include <string.h>
+ *     #include <ccan/grab_file/grab_file.h>
+ *     #include <ccan/talloc/talloc.h> // For talloc_free()
  *
  *     int main(int argc, char *argv[])
  *     {
  *
  *     int main(int argc, char *argv[])
  *     {
index 7061762fda6c8f7672de2d80b7db20b6ad87343b..003887c98cda687548218dbc45b75ab659e69504 100644 (file)
@@ -12,7 +12,9 @@
  *
  * Example:
  *     #include <err.h>
  *
  * Example:
  *     #include <err.h>
- *     #include "list/list.h"
+ *     #include <stdio.h>
+ *     #include <stdlib.h>
+ *     #include <ccan/list/list.h>
  *
  *     struct parent {
  *             const char *name;
  *
  *     struct parent {
  *             const char *name;
@@ -35,7 +37,8 @@
  *                     errx(1, "Usage: %s parent children...", argv[0]);
  *
  *             p.name = argv[1];
  *                     errx(1, "Usage: %s parent children...", argv[0]);
  *
  *             p.name = argv[1];
- *             for (i = 2; i < argc, i++) {
+ *             list_head_init(&p.children);
+ *             for (i = 2; i < argc; i++) {
  *                     c = malloc(sizeof(*c));
  *                     c->name = argv[i];
  *                     list_add(&p.children, &c->list);
  *                     c = malloc(sizeof(*c));
  *                     c->name = argv[i];
  *                     list_add(&p.children, &c->list);
index 32ced7d8ed7b791609ec3546300adbd1c65fbe17..fee413d3bbc90b23a756bc3a1b7eefb8a1c019e0 100644 (file)
  *     #include <sys/types.h>
  *     #include <sys/stat.h>
  *     #include <fcntl.h>
  *     #include <sys/types.h>
  *     #include <sys/stat.h>
  *     #include <fcntl.h>
+ *     #include <stdbool.h>
+ *     #include <string.h>
+ *     #include <errno.h>
+ *     #include <ccan/noerr/noerr.h>
  *
  *     bool write_string_to_file(const char *file, const char *string)
  *     {
  *
  *     bool write_string_to_file(const char *file, const char *string)
  *     {
index 4baea773654c6baf7da634b3c0dfecefd5b9a62f..081e862d6d69fd7109c1f45ca4733923f5d91a7e 100644 (file)
@@ -9,7 +9,8 @@
  * the standard string.h.
  *
  * Example:
  * the standard string.h.
  *
  * Example:
- *     #include "str/str.h"
+ *     #include <stdio.h>
+ *     #include <ccan/str/str.h>
  *
  *     int main(int argc, char *argv[])
  *     {
  *
  *     int main(int argc, char *argv[])
  *     {
index 3186b2bacbc68e70e09536d06ca910ce841ba6cf..aaf9d996d0f5553ef5fc554a44bd39631e5e2055 100644 (file)
@@ -10,9 +10,9 @@
  * string utilities in "str.h".
  *
  * Example:
  * string utilities in "str.h".
  *
  * Example:
- *     #include "str_talloc/str_talloc.h"
- *     #include "talloc/talloc.h"
- *     #include "grab_file/grab_file.h"
+ *     #include <ccan/str_talloc/str_talloc.h>
+ *     #include <ccan/talloc/talloc.h>
+ *     #include <ccan/grab_file/grab_file.h>
  *     #include <err.h>
  *     
  *     // Dumb demo program to double-linespace a file.
  *     #include <err.h>
  *     
  *     // Dumb demo program to double-linespace a file.
index 2a978801cdb4fd87d2309e9891339e09fb3ec999..95c91536b3fafa98d9cac86917d248d7c5bbbbd7 100644 (file)
@@ -31,9 +31,9 @@
  *     #include <stdio.h>
  *     #include <stdarg.h>
  *     #include <err.h>
  *     #include <stdio.h>
  *     #include <stdarg.h>
  *     #include <err.h>
- *     #include "talloc/talloc.h"
+ *     #include <ccan/talloc/talloc.h>
  *
  *
- *     // A structure containing a popened comman.
+ *     // A structure containing a popened command.
  *     struct command
  *     {
  *             FILE *f;
  *     struct command
  *     {
  *             FILE *f;
@@ -79,7 +79,7 @@
  *             struct command *cmd;
  *
  *             if (argc != 2)
  *             struct command *cmd;
  *
  *             if (argc != 2)
- *                     errx(1, "Usage: %s <command>\n");
+ *                     errx(1, "Usage: %s <command>\n", argv[0]);
  *
  *             cmd = open_output_cmd(NULL, "%s hello", argv[1]);
  *             if (!cmd)
  *
  *             cmd = open_output_cmd(NULL, "%s hello", argv[1]);
  *             if (!cmd)
index 2e628914ed2da5a1aeaa6618be9abfc184e90da3..010f98967470528b4425a4b578bd9f8df9ef5340 100644 (file)
@@ -20,7 +20,7 @@
  *
  * Example:
  *     #include <string.h>
  *
  * Example:
  *     #include <string.h>
- *     #include "tap/tap.h"
+ *     #include <ccan/tap/tap.h>
  *
  *     // Run some simple (but overly chatty) tests on strcmp().
  *     int main(int argc, char *argv[])
  *
  *     // Run some simple (but overly chatty) tests on strcmp().
  *     int main(int argc, char *argv[])