Line data Source code
1 : #include "source/extensions/compression/gzip/common/base.h" 2 : 3 : namespace Envoy { 4 : namespace Extensions { 5 : namespace Compression { 6 : namespace Gzip { 7 : namespace Common { 8 : 9 : Base::Base(uint64_t chunk_size, std::function<void(z_stream*)> zstream_deleter) 10 : : chunk_size_{chunk_size}, chunk_char_ptr_(new unsigned char[chunk_size]), 11 1516 : zstream_ptr_(new z_stream(), zstream_deleter) {} 12 : 13 1200 : uint64_t Base::checksum() { return zstream_ptr_->adler; } 14 : 15 332120 : void Base::updateOutput(Buffer::Instance& output_buffer) { 16 332120 : const uint64_t n_output = chunk_size_ - zstream_ptr_->avail_out; 17 332120 : if (n_output == 0) { 18 130073 : return; 19 130073 : } 20 : 21 202047 : output_buffer.add(static_cast<void*>(chunk_char_ptr_.get()), n_output); 22 202047 : zstream_ptr_->avail_out = chunk_size_; 23 202047 : zstream_ptr_->next_out = chunk_char_ptr_.get(); 24 202047 : } 25 : 26 : } // namespace Common 27 : } // namespace Gzip 28 : } // namespace Compression 29 : } // namespace Extensions 30 : } // namespace Envoy