Created
July 19, 2022 16:38
-
-
Save KartikShrivastava/0675a81bbb4920bd8ac239b6bbe1f015 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::unique_ptr<char[]> Decoder::decompress(size_t &length, size_t off) { | |
std::unique_ptr<char[]> src = read(length, off); | |
z_stream zs = {}; // zero-initialize | |
// using inflateInit2 with windowBits(2nd argument) set to MAX_WBITS | 32, triggers header detection to properly | |
// decompress both zlib and gzip streams | |
if (inflateInit2(&zs, MAX_WBITS | 32) != Z_OK) { | |
errStream << "Failed to initialize zlib inflate" << std::endl; | |
return nullptr; | |
} | |
// code truncated ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment