Commit cbb99113 authored by Rusty Russell's avatar Rusty Russell

charset: make example use tal/grab_file instead of grab_file.

Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent e22289e9
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
* #include <stdlib.h> * #include <stdlib.h>
* #include <string.h> * #include <string.h>
* #include <ccan/charset/charset.h> * #include <ccan/charset/charset.h>
* #include <ccan/grab_file/grab_file.h> * #include <ccan/tal/grab_file/grab_file.h>
* #include <ccan/talloc/talloc.h> * #include <ccan/tal/tal.h>
* *
* static void print_json_string(const char *s); * static void print_json_string(const char *s);
* static bool parse_hex16(const char **sp, unsigned int *out); * static bool parse_hex16(const char **sp, unsigned int *out);
...@@ -24,23 +24,22 @@ ...@@ -24,23 +24,22 @@
* int main(void) * int main(void)
* { * {
* char *input; * char *input;
* size_t length;
* *
* input = grab_file(NULL, NULL, &length); * input = grab_file(NULL, NULL);
* if (!input) * if (!input)
* err(1, "Error reading input"); * err(1, "Error reading input");
* if (!utf8_validate(input, length)) { * if (!utf8_validate(input, tal_count(input)-1)) {
* fprintf(stderr, "Input contains invalid UTF-8\n"); * fprintf(stderr, "Input contains invalid UTF-8\n");
* return 1; * return 1;
* } * }
* if (strlen(input) != length) { * if (strlen(input) != tal_count(input)-1) {
* fprintf(stderr, "Input contains null characters\n"); * fprintf(stderr, "Input contains null characters\n");
* return 1; * return 1;
* } * }
* *
* print_json_string(input); * print_json_string(input);
* *
* talloc_free(input); * tal_free(input);
* return 0; * return 0;
* } * }
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment