Line data Source code
1 : #include "source/extensions/compression/zstd/common/base.h" 2 : 3 : namespace Envoy { 4 : namespace Extensions { 5 : namespace Compression { 6 : namespace Zstd { 7 : namespace Common { 8 : 9 : Base::Base(uint32_t chunk_size) 10 : : chunk_ptr_{std::make_unique<uint8_t[]>(chunk_size)}, output_{chunk_ptr_.get(), chunk_size, 0}, 11 0 : input_{nullptr, 0, 0} {} 12 : 13 0 : void Base::setInput(const Buffer::RawSlice& input_slice) { 14 0 : input_.src = static_cast<uint8_t*>(input_slice.mem_); 15 0 : input_.pos = 0; 16 0 : input_.size = input_slice.len_; 17 0 : } 18 : 19 0 : void Base::getOutput(Buffer::Instance& output_buffer) { 20 0 : if (output_.pos > 0) { 21 0 : output_buffer.add(static_cast<void*>(chunk_ptr_.get()), output_.pos); 22 0 : output_.pos = 0; 23 0 : output_.dst = chunk_ptr_.get(); 24 0 : } 25 0 : } 26 : 27 : } // namespace Common 28 : } // namespace Zstd 29 : } // namespace Compression 30 : } // namespace Extensions 31 : } // namespace Envoy