commit - 54d5be07768d1e312078b5eb60f0e32738a1631a
commit + 3b9e6fcfb6688f928cfe62fee08d34d6c8d85992
blob - a9a36a64dd1519966e9aa8699e80bd93c895bdbf
blob + 02f9a9d5925c144aab1275b46ce59112abff7023
--- lib/deflate.c
+++ lib/deflate.c
#endif
const struct got_error *
-got_deflate_init(struct got_deflate_buf *zb, uint8_t *outbuf, size_t bufsize,
- struct got_deflate_checksum *csum)
+got_deflate_init(struct got_deflate_buf *zb, uint8_t *outbuf, size_t bufsize)
{
const struct got_error *err = NULL;
int zerr;
zb->flags |= GOT_DEFLATE_F_OWN_OUTBUF;
} else
zb->outbuf = outbuf;
-
- zb->csum = csum;
done:
if (err)
got_deflate_end(zb);
*outlenp = 0;
do {
- char *csum_out = NULL;
- size_t csum_avail = 0;
-
if (z->avail_in == 0) {
size_t n = fread(zb->inbuf, 1, zb->inlen, f);
if (n == 0) {
z->next_in = zb->inbuf;
z->avail_in = n;
}
- if (zb->csum) {
- csum_out = z->next_out;
- csum_avail = z->avail_out;
- }
ret = deflate(z, Z_NO_FLUSH);
- if (zb->csum) {
- csum_output(zb->csum, csum_out,
- csum_avail - z->avail_out);
- }
} while (ret == Z_OK && z->avail_out > 0);
if (ret == Z_OK) {
size_t avail;
struct got_deflate_buf zb;
- err = got_deflate_init(&zb, NULL, GOT_DEFLATE_BUFSIZE, csum);
+ err = got_deflate_init(&zb, NULL, GOT_DEFLATE_BUFSIZE);
if (err)
goto done;
err = got_ferror(outfile, GOT_ERR_IO);
goto done;
}
+ if (csum)
+ csum_output(csum, zb.outbuf, avail);
*outlen += avail;
}
} while (zb.flags & GOT_DEFLATE_F_HAVE_MORE);
blob - c359d7c4cfbe99e2e20a5f7798a73ce6a55257c3
blob + bb41647fe85bfae60cb467b43a93a531452887de
--- lib/got_lib_deflate.h
+++ lib/got_lib_deflate.h
int flags;
#define GOT_DEFLATE_F_HAVE_MORE 0x01
#define GOT_DEFLATE_F_OWN_OUTBUF 0x02
- struct got_deflate_checksum *csum;
};
#define GOT_DEFLATE_BUFSIZE 8192
const struct got_error *got_deflate_init(struct got_deflate_buf *, uint8_t *,
- size_t, struct got_deflate_checksum *);
+ size_t);
const struct got_error *got_deflate_read(struct got_deflate_buf *, FILE *,
size_t *);
void got_deflate_end(struct got_deflate_buf *);