commit f1397fcb9de517312a6924a0f0af6bb232bc9658 from: Stefan Sperling date: Fri Apr 14 22:24:43 2023 UTC remove unused function got_read_file_to_mem() commit - 2f43cd698e3fcc3000262b3e0f3a2119f06345bb commit + f1397fcb9de517312a6924a0f0af6bb232bc9658 blob - e0d04d5ded1ba4a6804afe49bf9df83eda5d2250 blob + ff0be54ad39998cf5dffd4bd99a222298cd15e06 --- lib/got_lib_object_parse.h +++ lib/got_lib_object_parse.h @@ -41,7 +41,6 @@ const struct got_error *got_object_parse_tag(struct go uint8_t *, size_t); const struct got_error *got_object_read_tag(struct got_tag_object **, int, struct got_object_id *, size_t); -const struct got_error *got_read_file_to_mem(uint8_t **, size_t *, FILE *); struct got_pack; struct got_packidx; blob - b5229cd68c12aaa23558c7fd20e171ae4aed35ce blob + 28536b3cc7243ce070909cda1331a2b7750713e0 --- lib/object_parse.c +++ lib/object_parse.c @@ -1152,52 +1152,3 @@ done: got_object_close(obj); return err; } - -const struct got_error * -got_read_file_to_mem(uint8_t **outbuf, size_t *outlen, FILE *f) -{ - const struct got_error *err = NULL; - static const size_t blocksize = 512; - size_t n, total, remain; - uint8_t *buf; - - *outbuf = NULL; - *outlen = 0; - - buf = malloc(blocksize); - if (buf == NULL) - return got_error_from_errno("malloc"); - - remain = blocksize; - total = 0; - for (;;) { - if (remain == 0) { - uint8_t *newbuf; - newbuf = reallocarray(buf, 1, total + blocksize); - if (newbuf == NULL) { - err = got_error_from_errno("reallocarray"); - goto done; - } - buf = newbuf; - remain += blocksize; - } - n = fread(buf + total, 1, remain, f); - if (n == 0) { - if (ferror(f)) { - err = got_ferror(f, GOT_ERR_IO); - goto done; - } - break; /* EOF */ - } - remain -= n; - total += n; - }; - -done: - if (err == NULL) { - *outbuf = buf; - *outlen = total; - } else - free(buf); - return err; -}