diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2015-12-27 18:39:47 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2015-12-27 18:40:08 +0900 |
| commit | b1132d6b10cd3791b9529d7031d723fd0e2d8215 (patch) | |
| tree | 9ce465b42bf09372118335c7c619bb2b41869eaf /src/GZipEncoder.cc | |
| parent | 4abad2f64c9ff80144a61c5a9c2bea144852b883 (diff) | |
make clang-format using clang-format-3.6
Diffstat (limited to 'src/GZipEncoder.cc')
| -rw-r--r-- | src/GZipEncoder.cc | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/GZipEncoder.cc b/src/GZipEncoder.cc index 0a46be5a..884485ee 100644 --- a/src/GZipEncoder.cc +++ b/src/GZipEncoder.cc @@ -43,12 +43,9 @@ namespace aria2 { -GZipEncoder::GZipEncoder():strm_(nullptr) {} +GZipEncoder::GZipEncoder() : strm_(nullptr) {} -GZipEncoder::~GZipEncoder() -{ - release(); -} +GZipEncoder::~GZipEncoder() { release(); } void GZipEncoder::init() { @@ -60,39 +57,38 @@ void GZipEncoder::init() strm_->avail_in = 0; strm_->next_in = Z_NULL; - if(Z_OK != deflateInit2 - (strm_, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 31, 9, Z_DEFAULT_STRATEGY)) { + if (Z_OK != deflateInit2(strm_, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 31, 9, + Z_DEFAULT_STRATEGY)) { throw DL_ABORT_EX("Initializing z_stream failed."); } } void GZipEncoder::release() { - if(strm_) { + if (strm_) { deflateEnd(strm_); delete strm_; strm_ = nullptr; } } -std::string GZipEncoder::encode -(const unsigned char* in, size_t length, int flush) +std::string GZipEncoder::encode(const unsigned char* in, size_t length, + int flush) { strm_->avail_in = length; strm_->next_in = const_cast<unsigned char*>(in); std::string out; std::array<unsigned char, 4_k> outbuf; - while(1) { + while (1) { strm_->avail_out = outbuf.size(); strm_->next_out = outbuf.data(); int ret = ::deflate(strm_, flush); - if(ret == Z_STREAM_ERROR) { - throw DL_ABORT_EX(fmt("libz::deflate() failed. cause:%s", - strm_->msg)); + if (ret == Z_STREAM_ERROR) { + throw DL_ABORT_EX(fmt("libz::deflate() failed. cause:%s", strm_->msg)); } size_t produced = outbuf.size() - strm_->avail_out; out.append(&outbuf[0], &outbuf[produced]); - if(strm_->avail_out > 0) { + if (strm_->avail_out > 0) { break; } } @@ -113,8 +109,8 @@ GZipEncoder& GZipEncoder::operator<<(const char* s) GZipEncoder& GZipEncoder::operator<<(const std::string& s) { - internalBuf_ += encode - (reinterpret_cast<const unsigned char*>(s.data()), s.size()); + internalBuf_ += + encode(reinterpret_cast<const unsigned char*>(s.data()), s.size()); return *this; } |
