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
172
    : chunk_size_{chunk_size}, chunk_char_ptr_(new unsigned char[chunk_size]),
11
172
      zstream_ptr_(new z_stream(), zstream_deleter) {}
12

            
13
89
uint64_t Base::checksum() { return zstream_ptr_->adler; }
14

            
15
17471
void Base::updateOutput(Buffer::Instance& output_buffer) {
16
17471
  const uint64_t n_output = chunk_size_ - zstream_ptr_->avail_out;
17
17471
  if (n_output == 0) {
18
8
    return;
19
8
  }
20

            
21
17463
  output_buffer.add(static_cast<void*>(chunk_char_ptr_.get()), n_output);
22
17463
  zstream_ptr_->avail_out = chunk_size_;
23
17463
  zstream_ptr_->next_out = chunk_char_ptr_.get();
24
17463
}
25

            
26
} // namespace Common
27
} // namespace Gzip
28
} // namespace Compression
29
} // namespace Extensions
30
} // namespace Envoy