X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fdoc_extract.c;h=b70325ea47f51a00f7db114024bbbc24e2089920;hp=aa3f2206cc3bace91b18b657690d2d282084a9a1;hb=e52dc42bad9a6637fbec44fe08705a51f6f84a94;hpb=779d83085d6c6d37f6c4030130efe649a005696a diff --git a/tools/doc_extract.c b/tools/doc_extract.c index aa3f2206..b70325ea 100644 --- a/tools/doc_extract.c +++ b/tools/doc_extract.c @@ -11,35 +11,6 @@ #include "talloc/talloc.h" #include "string/string.h" -/* This version adds one byte (for nul term) */ -static void *grab_file(void *ctx, const char *filename) -{ - unsigned int max = 16384, size = 0; - int ret, fd; - char *buffer; - - if (streq(filename, "-")) - fd = dup(STDIN_FILENO); - else - fd = open(filename, O_RDONLY, 0); - - if (fd < 0) - return NULL; - - buffer = talloc_array(ctx, char, max+1); - while ((ret = read(fd, buffer + size, max - size)) > 0) { - size += ret; - if (size == max) - buffer = talloc_realloc(ctx, buffer, char, max*=2 + 1); - } - if (ret < 0) { - talloc_free(buffer); - buffer = NULL; - } else - buffer[size] = '\0'; - close(fd); - return buffer; -} int main(int argc, char *argv[]) {