From 6c237850e90dce317ede7b0d4e53125df15ab62b Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 16 Sep 2020 19:35:43 -0700 Subject: WIP --- utils.c | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'utils.c') diff --git a/utils.c b/utils.c index 7844934..6b9af5c 100644 --- a/utils.c +++ b/utils.c @@ -153,28 +153,5 @@ size_t unescape_string(char *dest, const char *src, size_t bufsize) #undef PUT } -/* - * Read an entire file into memory. (Guaranteeing that ret[-1] == '\0') - */ -char *readfile(int fd) -{ - size_t capacity = 1000, len = 0; - char *buf = calloc(sizeof(char), capacity+1); - buf[len++] = '\0'; - ssize_t just_read; - while ((just_read=read(fd, &buf[len], capacity-len)) > 0) { - len += (size_t)just_read; - if (len >= capacity) - buf = realloc(buf, sizeof(char)*(capacity *= 2)); - } - buf[len] = '\0'; - close(fd); - return &buf[1]; -} - -void freefile(char *f) -{ - free(&f[-1]); -} // vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1 -- cgit v1.2.3