X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=lib%2Fgunzip.c;h=832b3064e7614bc7c74159ca04f62b3122420356;hb=d025021e981fc2c06e95a3512f81f799f45d1f9c;hp=80b157f99eb4844dbade0925b0f20c0850d2bda5;hpb=82d72a1b9967cff4908f22c57536c3660f794401;p=oweals%2Fu-boot.git diff --git a/lib/gunzip.c b/lib/gunzip.c index 80b157f99e..832b3064e7 100644 --- a/lib/gunzip.c +++ b/lib/gunzip.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -105,7 +106,7 @@ void gzwrite_progress_finish(int returnval, } int gzwrite(unsigned char *src, int len, - struct block_dev_desc *dev, + struct blk_desc *dev, unsigned long szwritebuf, u64 startoffs, u64 szexpected) @@ -193,7 +194,7 @@ int gzwrite(unsigned char *src, int len, s.next_in = src + i; s.avail_in = payload_size+8; - writebuf = (unsigned char *)malloc(szwritebuf); + writebuf = (unsigned char *)malloc_cache_aligned(szwritebuf); /* decompress until deflate stream ends or end of file */ do { @@ -232,9 +233,8 @@ int gzwrite(unsigned char *src, int len, gzwrite_progress(iteration++, totalfilled, szexpected); - blocks_written = dev->block_write(dev, outblock, - writeblocks, - writebuf); + blocks_written = blk_dwrite(dev, outblock, + writeblocks, writebuf); outblock += blocks_written; if (ctrlc()) { puts("abort\n"); @@ -286,12 +286,11 @@ int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp, do { r = inflate(&s, Z_FINISH); if (stoponerr == 1 && r != Z_STREAM_END && - (s.avail_out == 0 || r != Z_BUF_ERROR)) { + (s.avail_in == 0 || s.avail_out == 0 || r != Z_BUF_ERROR)) { printf("Error: inflate() returned %d\n", r); err = -1; break; } - s.avail_in = *lenp - offset - (int)(s.next_out - (unsigned char*)dst); } while (r == Z_BUF_ERROR); *lenp = s.next_out - (unsigned char *) dst; inflateEnd(&s);