commit - 4b57020975f73d8c07712c7d26151f50205df436
commit + 6fb3a4970337c135644ac0ef619a7e96616e4230
blob - f90aa5f4ddf0dd9604fea24747c458881d7c75ec
blob + 90304d53d37a65e9e7ed2a7006e82d694b650c1a
--- lib/got_lib_inflate.h
+++ lib/got_lib_inflate.h
const struct got_error *got_inflate_init(struct got_inflate_buf *, uint8_t *,
size_t);
const struct got_error *got_inflate_read(struct got_inflate_buf *, FILE *,
- size_t *);
+ size_t *, size_t *);
const struct got_error *got_inflate_read_fd(struct got_inflate_buf *, int,
size_t *);
const struct got_error *got_inflate_read_mmap(struct got_inflate_buf *,
uint8_t *, size_t, size_t, size_t *, size_t *);
void got_inflate_end(struct got_inflate_buf *);
-const struct got_error *got_inflate_to_mem(uint8_t **, size_t *, FILE *);
+const struct got_error *got_inflate_to_mem(uint8_t **, size_t *, size_t *,
+ FILE *);
const struct got_error *got_inflate_to_mem_fd(uint8_t **, size_t *, int);
const struct got_error *got_inflate_to_mem_mmap(uint8_t **, size_t *, uint8_t *,
size_t, size_t);
blob - 472aaa11edacfa2b14007043174136b80ff00ba9
blob + 02b01b5e5827923af47d173a9b3c62a8eab8922f
--- lib/inflate.c
+++ lib/inflate.c
}
const struct got_error *
-got_inflate_read(struct got_inflate_buf *zb, FILE *f, size_t *outlenp)
+got_inflate_read(struct got_inflate_buf *zb, FILE *f, size_t *outlenp,
+ size_t *consumed)
{
size_t last_total_out = zb->z.total_out;
+ size_t last_total_in = zb->z.total_in;
z_stream *z = &zb->z;
int ret = Z_ERRNO;
z->avail_out = zb->outlen;
*outlenp = 0;
+ if (consumed)
+ *consumed = 0;
do {
if (z->avail_in == 0) {
size_t n = fread(zb->inbuf, 1, zb->inlen, f);
}
*outlenp = z->total_out - last_total_out;
+ if (consumed)
+ *consumed += z->total_in - last_total_in;
return NULL;
}
}
const struct got_error *
-got_inflate_to_mem(uint8_t **outbuf, size_t *outlen, FILE *f)
+got_inflate_to_mem(uint8_t **outbuf, size_t *outlen,
+ size_t *consumed_total, FILE *f)
{
const struct got_error *err;
- size_t avail;
+ size_t avail, consumed;
struct got_inflate_buf zb;
void *newbuf;
int nbuf = 1;
return err;
*outlen = 0;
+ if (consumed_total)
+ *consumed_total = 0;
do {
- err = got_inflate_read(&zb, f, &avail);
+ err = got_inflate_read(&zb, f, &avail, &consumed);
if (err)
goto done;
*outlen += avail;
+ if (consumed_total)
+ *consumed_total += consumed;
if (zb.flags & GOT_INFLATE_F_HAVE_MORE) {
newbuf = reallocarray(*outbuf, ++nbuf,
GOT_INFLATE_BUFSIZE);
*outlen = 0;
do {
- err = got_inflate_read(&zb, infile, &avail);
+ err = got_inflate_read(&zb, infile, &avail, NULL);
if (err)
goto done;
if (avail > 0) {
*outlen = 0;
do {
- err = got_inflate_read(&zb, infile, &avail);
+ err = got_inflate_read(&zb, infile, &avail, NULL);
if (err)
goto done;
if (avail > 0) {
blob - c1ce38c213a13c5547fb6643db2aa79a36185545
blob + 1e044637ec38d03deda6d442ef53cad1853a8456
--- libexec/got-index-pack/got-index-pack.c
+++ libexec/got-index-pack/got-index-pack.c
goto error;
if(hasheq(&o->hash, &h))
goto error;
- if ((e = got_inflate_to_mem(&d, &n, f)) != NULL)
+ if ((e = got_inflate_to_mem(&d, &n, NULL, f)) != NULL)
goto error;
o->len = ftello(f) - o->off;
if(d == NULL || n != nd)
goto error;
}
- if (got_inflate_to_mem(&d, &n, f) != NULL)
+ if (got_inflate_to_mem(&d, &n, NULL, f) != NULL)
goto error;
o->len = ftello(f) - o->off;
if(d == NULL || n != nd)
b.data = emalloc(b.sz);
n = snprintf(b.data, 64, "%s %lld", typestr(t), l) + 1;
b.len = n;
- e = got_inflate_to_mem(&data, &ndata, f);
+ e = got_inflate_to_mem(&data, &ndata, NULL, f);
if (e != NULL || n + ndata >= b.sz) {
free(b.data);
return -1;
size_t n;
int l;
- if (got_inflate_to_mem(&d, &n, f) != NULL)
+ if (got_inflate_to_mem(&d, &n, NULL, f) != NULL)
return -1;
s = (char *)d;
blob - 02a103779a91cce8d7052cb4234b3aab5431b57d
blob + 259da2e7e9b6fd36089b5396d4ef34f94744a694
--- libexec/got-read-blob/got-read-blob.c
+++ libexec/got-read-blob/got-read-blob.c
if (obj->size + obj->hdrlen <=
GOT_PRIVSEP_INLINE_BLOB_DATA_MAX) {
- err = got_inflate_to_mem(&buf, &size, f);
+ err = got_inflate_to_mem(&buf, &size, NULL, f);
if (err)
goto done;
} else {
blob - 546aa7c0b0739f71ac9bf7d92006ee13fdb65fc4
blob + 24e3dce4fa25b6cdd345bf34190e5a0c4c476dba
--- libexec/got-read-commit/got-read-commit.c
+++ libexec/got-read-commit/got-read-commit.c
size_t len;
uint8_t *p;
- err = got_inflate_to_mem(&p, &len, f);
+ err = got_inflate_to_mem(&p, &len, NULL, f);
if (err)
return err;
blob - 5839f14c44eb5fd1c9f7d9c59752aaff7d7e5bfb
blob + c9959de2131e52c0fd9d5bdd3d72e5504cdfaeb8
--- libexec/got-read-tag/got-read-tag.c
+++ libexec/got-read-tag/got-read-tag.c
size_t len;
uint8_t *p;
- err = got_inflate_to_mem(&p, &len, f);
+ err = got_inflate_to_mem(&p, &len, NULL, f);
if (err)
return err;
blob - dc6d4d5dee5cf370fb3fd6389ea727153a2f965c
blob + 577f7c91bd72d65e5741061fa641b0b5b20237f6
--- libexec/got-read-tree/got-read-tree.c
+++ libexec/got-read-tree/got-read-tree.c
struct got_object *obj;
size_t len;
- err = got_inflate_to_mem(p, &len, f);
+ err = got_inflate_to_mem(p, &len, NULL, f);
if (err)
return err;