Skip to content

Commit 117ab45

Browse files
Add comment for DeflateInit2
1 parent 5687a0c commit 117ab45

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/fwrite.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,13 @@ int init_stream(z_stream *stream) {
564564
stream->zalloc = Z_NULL;
565565
stream->zfree = Z_NULL;
566566
stream->opaque = Z_NULL;
567+
// In deflateInit2, windowBits can be –8..–15 for raw deflate, 15 is the bigger window size.
568+
// With -15, deflate() will generate raw deflate data with no zlib header or trailer, and will not compute a check value.
569+
// Previously this parameter was 31 baecause windowBits can be greater than 15 for optional gzip encoding.
570+
// Adding 16 writes a simple gzip header and trailer around the compressed data.
571+
// Now we manage header and trailer. gzip file is slighty lower with -15 because no header/trailer are
572+
// written for each chunk.
573+
// For memLevel, 8 is the default value (128 KiB). memLevel=9 uses maximum memory for optimal speed. To be tested ?
567574
int err = deflateInit2(stream, gzip_level, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY);
568575
return err; // # nocov
569576
}

0 commit comments

Comments
 (0)