diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2023-08-31 14:29:49 +1000 |
---|---|---|
committer | Jim Mussared <jim.mussared@gmail.com> | 2023-09-01 12:23:37 +1000 |
commit | 32db4c58f7aebc18e425f67e9f2585a79d34febf (patch) | |
tree | e9f268d7700d136d2e0d34ccc3f0d6f28a1fc672 /lib | |
parent | 81c19d93bc687e2bd953af16c9d779a97e822e5f (diff) |
extmod/moddeflate: Change default window size.
The primary purpose of this commit is to make decompress default to
wbits=15 when the format is gzip (or auto format with gzip detected). The
idea is that someone decompressing a gzip stream should be able to use the
default `deflate.DeflateIO(f)` and it will "just work" for any input
stream, even though it uses a lot of memory.
This is done by making uzlib report gzip files as having wbits set to 15
in their header (where it previously only set the wbits out parameter for
zlib files), and then fixing up the logic in `deflateio_init_read`.
Updates the documentation to match.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/uzlib/header.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/uzlib/header.c b/lib/uzlib/header.c index edd2b08ab..9c48d9139 100644 --- a/lib/uzlib/header.c +++ b/lib/uzlib/header.c @@ -108,6 +108,10 @@ int uzlib_parse_zlib_gzip_header(uzlib_uncomp_t *d, int *wbits) d->checksum_type = UZLIB_CHKSUM_CRC; d->checksum = ~0; + /* gzip does not include the window size in the header, as it is expected that a + compressor will use wbits=15 (32kiB).*/ + *wbits = 15; + return UZLIB_HEADER_GZIP; } else { /* check checksum */ |