Skip to content

Commit

Permalink
Merge pull request #3 from yikenan/master
Browse files Browse the repository at this point in the history
fix memory leak
  • Loading branch information
lganzzzo authored Dec 23, 2021
2 parents a2703aa + 280b29b commit e731806
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/oatpp-zlib/Processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ DeflateEncoder::DeflateEncoder(v_buff_size bufferSize, bool gzip, v_int32 compre

}

DeflateEncoder::~DeflateEncoder() {
v_int32 res = deflateEnd(&m_zStream);
if(res != Z_OK) {
OATPP_LOGE("[oatpp::zlib::DeflateEncoder::~DeflateEncoder()]", "Error. Failed call to 'deflateEnd()'.")
}
}

v_io_size DeflateEncoder::suggestInputStreamReadSize() {
return m_bufferSize;
}
Expand Down Expand Up @@ -188,6 +195,13 @@ DeflateDecoder::DeflateDecoder(v_buff_size bufferSize, bool gzip)

}

DeflateDecoder::~DeflateDecoder() {
v_int32 res = inflateEnd(&m_zStream);
if(res != Z_OK) {
OATPP_LOGE("[oatpp::zlib::DeflateDecoder::~DeflateDecoder()]", "Error. Failed call to 'inflateEnd()'.")
}
}

v_io_size DeflateDecoder::suggestInputStreamReadSize() {
return m_bufferSize;
}
Expand Down
4 changes: 4 additions & 0 deletions src/oatpp-zlib/Processor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class DeflateEncoder : public oatpp::data::buffer::Processor {
*/
DeflateEncoder(v_buff_size bufferSize = 1024, bool gzip = false, v_int32 compressionLevel = Z_DEFAULT_COMPRESSION);

~DeflateEncoder();

/**
* If the client is using the input stream to read data and push it to the processor,
* the client MAY ask the processor for a suggested read size.
Expand Down Expand Up @@ -93,6 +95,8 @@ class DeflateDecoder : public oatpp::data::buffer::Processor {
*/
DeflateDecoder(v_buff_size bufferSize = 1024, bool gzip = false);

~DeflateDecoder();

/**
* If the client is using the input stream to read data and push it to the processor,
* the client MAY ask the processor for a suggested read size.
Expand Down

0 comments on commit e731806

Please sign in to comment.