Skip to content

Commit

Permalink
Merge branch 'ex13' into ex14
Browse files Browse the repository at this point in the history
  • Loading branch information
Rconybea committed Feb 11, 2024
2 parents 005ec75 + 3f142f9 commit 1f22460
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion compression/deflate_zstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ deflate_zstream::deflate_zstream()
zstream_.avail_out = 0;
zstream_.next_out = Z_NULL;

int ret = ::deflateInit(&zstream_, Z_DEFAULT_COMPRESSION);
//int ret = ::deflateInit(&zstream_, Z_DEFAULT_COMPRESSION);
int ret = ::deflateInit2(&zstream_,
Z_DEFAULT_COMPRESSION,
Z_DEFLATED,
MAX_WBITS + 16 /* +16 tells zlib to write .gzip header*/,
8 /*memlevel 1-9; higher to spend memory for more speed+compression. default=8*/,
Z_DEFAULT_STRATEGY);

if (ret != Z_OK)
throw runtime_error("deflate_zstream: failed to initialize .zstream");
Expand Down
4 changes: 3 additions & 1 deletion compression/inflate_zstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ inflate_zstream::inflate_zstream() {
zstream_.avail_out = 0;
zstream_.next_out = Z_NULL;

int ret = ::inflateInit(&zstream_);
//int ret = ::inflateInit(&zstream_);
int ret = ::inflateInit2(&zstream_,
MAX_WBITS + 32 /* +32 tells zlib to detect zlib/gzip encoding + handle either*/);

if (ret != Z_OK)
throw std::runtime_error("inflate_zstream: failed to initialize .zstream");
Expand Down

0 comments on commit 1f22460

Please sign in to comment.