diff options
author | Tim Rühsen <tim.ruehsen@gmx.de> | 2023-02-12 13:56:46 +0100 |
---|---|---|
committer | Tim Rühsen <tim.ruehsen@gmx.de> | 2023-02-18 17:26:23 +0100 |
commit | c77c95033a4e6f96d79c1c2cb8c981cba9276cf5 (patch) | |
tree | 071ace1859a1c7f4a8d3849cbfa1c8fa34dddaeb | |
parent | af1100f2994577bd8391cae4df449952169b4b7b (diff) | |
download | wget-c77c95033a4e6f96d79c1c2cb8c981cba9276cf5.tar.gz |
* src/retr.c (fd_read_body): Simplify gzip initialization
-rw-r--r-- | src/retr.c | 37 |
1 files changed, 14 insertions, 23 deletions
@@ -290,28 +290,19 @@ fd_read_body (const char *downloaded_filename, int fd, FILE *out, wgint toread, if (flags & rb_compressed_gzip) { gzbuf = xmalloc (gzbufsize); - if (gzbuf != NULL) + gzstream.zalloc = zalloc; + gzstream.zfree = zfree; + gzstream.opaque = Z_NULL; + gzstream.next_in = Z_NULL; + gzstream.avail_in = 0; + + #define GZIP_DETECT 32 /* gzip format detection */ + #define GZIP_WINDOW 15 /* logarithmic window size (default: 15) */ + ret = inflateInit2 (&gzstream, GZIP_DETECT | GZIP_WINDOW); + if (ret != Z_OK) { - gzstream.zalloc = zalloc; - gzstream.zfree = zfree; - gzstream.opaque = Z_NULL; - gzstream.next_in = Z_NULL; - gzstream.avail_in = 0; - - #define GZIP_DETECT 32 /* gzip format detection */ - #define GZIP_WINDOW 15 /* logarithmic window size (default: 15) */ - ret = inflateInit2 (&gzstream, GZIP_DETECT | GZIP_WINDOW); - if (ret != Z_OK) - { - xfree (gzbuf); - errno = (ret == Z_MEM_ERROR) ? ENOMEM : EINVAL; - ret = -1; - goto out; - } - } - else - { - errno = ENOMEM; + xfree (gzbuf); + errno = (ret == Z_MEM_ERROR) ? ENOMEM : EINVAL; ret = -1; goto out; } @@ -455,7 +446,7 @@ fd_read_body (const char *downloaded_filename, int fd, FILE *out, wgint toread, sum_read += ret; #ifdef HAVE_LIBZ - if (gzbuf != NULL) + if (gzbuf) { int err; int towrite; @@ -567,7 +558,7 @@ fd_read_body (const char *downloaded_filename, int fd, FILE *out, wgint toread, } #ifdef HAVE_LIBZ - if (gzbuf != NULL) + if (gzbuf) { int err = inflateEnd (&gzstream); if (ret >= 0) |