]> git.ozlabs.org Git - ccan/blobdiff - ccan/rbuf/_info
io: don't leave errno as a random value when we hit EOF.
[ccan] / ccan / rbuf / _info
index 30232db2cced60ede94bca9dbf6a4e6a3e153f5a..8a7d46e8c2f8270abf28fba1b012ca25ef27ab12 100644 (file)
@@ -1,5 +1,6 @@
-#include <string.h>
 #include "config.h"
+#include <stdio.h>
+#include <string.h>
 
 /**
  * rbuf - buffered I/O input primitive.
  *             char *word;
  *
  *             if (argv[1]) {
- *                     if (!rbuf_open(&in, argv[1], NULL, 0))
+ *                     if (!rbuf_open(&in, argv[1], NULL, 0, membuf_realloc))
  *                             err(1, "Failed opening %s", argv[1]);
  *             } else
- *                     rbuf_init(&in, STDIN_FILENO, NULL, 0);
+ *                     rbuf_init(&in, STDIN_FILENO, NULL, 0, membuf_realloc);
  *
- *             while ((word = rbuf_read_str(&in, ' ', realloc)) != NULL)
+ *             while ((word = rbuf_read_str(&in, ' ')) != NULL)
  *                     printf("%s*", word);
  *
  *             if (errno)
  *                     err(1, "Reading %s", argv[1] ? argv[1] : "<stdin>");
  *
  *             // Free the buffer, just because we can.
- *             free(in.buf);
+ *             free(rbuf_cleanup(&in));
  *             return 0;
  *     }
  */
@@ -45,6 +46,7 @@ int main(int argc, char *argv[])
                return 1;
 
        if (strcmp(argv[1], "depends") == 0) {
+               printf("ccan/membuf\n");
                return 0;
        }