bsdiff-portable

A more portable version of Colin Percival's bsdiff
git clone git://git.sgregoratto.me/bsdiff-portable
Log | Files | Refs | README | LICENSE

commit 2f64aeb31b8f4e9d17a3dccb09a069d15c2a7325
parent bd45371d268cb6da6692ab0b4efb76c8ee7bef40
Author: Matthew Endsley <mendsley@gmail.com>
Date:   Thu, 24 Sep 2020 00:19:36 +1000

save lengths in a single buffer, write once

Diffstat:
Mbsdiff.c | 16++++------------
1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/bsdiff.c b/bsdiff.c @@ -62,7 +62,7 @@ main(int argc, char **argv) off_t i; off_t dblen, eblen; uint8_t *db, *eb; - uint8_t buf[8]; + uint8_t buf[24]; struct bsdiff_header header = {"BSDIFF40", 0, 0, 0}; FILE *pf; BZFILE *pfbz2; @@ -211,17 +211,9 @@ main(int argc, char **argv) eblen += (scan - lenb) - (lastscan + lenf); offtout(lenf, buf); - BZ2_bzWrite(&bz2err, pfbz2, buf, 8); - if (bz2err != BZ_OK) - errx(1, "BZ2_bzWrite, bz2err = %d", bz2err); - - offtout((scan - lenb) - (lastscan + lenf), buf); - BZ2_bzWrite(&bz2err, pfbz2, buf, 8); - if (bz2err != BZ_OK) - errx(1, "BZ2_bzWrite, bz2err = %d", bz2err); - - offtout((pos - lenb) - (lastpos + lenf), buf); - BZ2_bzWrite(&bz2err, pfbz2, buf, 8); + offtout((scan - lenb) - (lastscan + lenf), buf + 8); + offtout((pos - lenb) - (lastpos + lenf), buf + 16); + BZ2_bzWrite(&bz2err, pfbz2, buf, sizeof(buf)); if (bz2err != BZ_OK) errx(1, "BZ2_bzWrite, bz2err = %d", bz2err);