Commit e57066ca authored by Ingvar Stepanyan's avatar Ingvar Stepanyan

Simplify z_stream initialisation

parent 441e079f
...@@ -29,12 +29,6 @@ namespace kj { ...@@ -29,12 +29,6 @@ namespace kj {
namespace _ { // private namespace _ { // private
GzipOutputContext::GzipOutputContext(kj::Maybe<int> compressionLevel) { GzipOutputContext::GzipOutputContext(kj::Maybe<int> compressionLevel) {
memset(&ctx, 0, sizeof(ctx));
ctx.next_in = nullptr;
ctx.avail_in = 0;
ctx.next_out = nullptr;
ctx.avail_out = 0;
int initResult; int initResult;
KJ_IF_MAYBE(level, compressionLevel) { KJ_IF_MAYBE(level, compressionLevel) {
...@@ -91,12 +85,6 @@ void GzipOutputContext::fail(int result) { ...@@ -91,12 +85,6 @@ void GzipOutputContext::fail(int result) {
GzipInputStream::GzipInputStream(InputStream& inner) GzipInputStream::GzipInputStream(InputStream& inner)
: inner(inner) { : inner(inner) {
memset(&ctx, 0, sizeof(ctx));
ctx.next_in = nullptr;
ctx.avail_in = 0;
ctx.next_out = nullptr;
ctx.avail_out = 0;
// windowBits = 15 (maximum) + magic value 16 to ask for gzip. // windowBits = 15 (maximum) + magic value 16 to ask for gzip.
KJ_ASSERT(inflateInit2(&ctx, 15 + 16) == Z_OK); KJ_ASSERT(inflateInit2(&ctx, 15 + 16) == Z_OK);
} }
...@@ -180,12 +168,6 @@ void GzipOutputStream::pump(int flush) { ...@@ -180,12 +168,6 @@ void GzipOutputStream::pump(int flush) {
GzipAsyncInputStream::GzipAsyncInputStream(AsyncInputStream& inner) GzipAsyncInputStream::GzipAsyncInputStream(AsyncInputStream& inner)
: inner(inner) { : inner(inner) {
memset(&ctx, 0, sizeof(ctx));
ctx.next_in = nullptr;
ctx.avail_in = 0;
ctx.next_out = nullptr;
ctx.avail_out = 0;
// windowBits = 15 (maximum) + magic value 16 to ask for gzip. // windowBits = 15 (maximum) + magic value 16 to ask for gzip.
KJ_ASSERT(inflateInit2(&ctx, 15 + 16) == Z_OK); KJ_ASSERT(inflateInit2(&ctx, 15 + 16) == Z_OK);
} }
......
...@@ -41,7 +41,7 @@ public: ...@@ -41,7 +41,7 @@ public:
private: private:
bool compressing; bool compressing;
z_stream ctx; z_stream ctx = {};
byte buffer[4096]; byte buffer[4096];
void fail(int result); void fail(int result);
...@@ -59,7 +59,7 @@ public: ...@@ -59,7 +59,7 @@ public:
private: private:
InputStream& inner; InputStream& inner;
z_stream ctx; z_stream ctx = {};
bool atValidEndpoint = false; bool atValidEndpoint = false;
byte buffer[4096]; byte buffer[4096];
...@@ -102,7 +102,7 @@ public: ...@@ -102,7 +102,7 @@ public:
private: private:
AsyncInputStream& inner; AsyncInputStream& inner;
z_stream ctx; z_stream ctx = {};
bool atValidEndpoint = false; bool atValidEndpoint = false;
byte buffer[4096]; byte buffer[4096];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment