Commit Diff


commit - 232c0ac1b26d38add9148b4e0382fc86c0cabd37
commit + 959773748b429b8c75f416f1df698cfdeb6a9b18
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 - e16496ab684e9fb134c63bfecd30b8dac21971ca
blob + ab0f787ecf3e24a140892c05ca1067f6cb66aecf
--- lib/object_parse.c
+++ lib/object_parse.c
@@ -1150,52 +1150,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;
-}