summaryrefslogtreecommitdiff
path: root/src/GZipEncoder.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2015-06-21 18:04:30 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2015-06-21 19:29:54 +0900
commit318c804504e32b7a0bbdbb35336d2e918000d80a (patch)
treefad396aee04c44a29ee79b33e1675db2275146c0 /src/GZipEncoder.cc
parent8ba9b0474747185708a25943fb6d2f97b3d9b17f (diff)
Use user-defined literal for k, m, and g (powers of 1024)
Diffstat (limited to 'src/GZipEncoder.cc')
-rw-r--r--src/GZipEncoder.cc12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/GZipEncoder.cc b/src/GZipEncoder.cc
index 2a3f6720..323faf19 100644
--- a/src/GZipEncoder.cc
+++ b/src/GZipEncoder.cc
@@ -42,10 +42,6 @@
namespace aria2 {
-namespace {
-const int OUTBUF_LENGTH = 4096;
-} // namespace
-
GZipEncoder::GZipEncoder():strm_(nullptr) {}
GZipEncoder::~GZipEncoder()
@@ -84,16 +80,16 @@ std::string GZipEncoder::encode
strm_->avail_in = length;
strm_->next_in = const_cast<unsigned char*>(in);
std::string out;
- unsigned char outbuf[OUTBUF_LENGTH];
+ std::array<unsigned char, 4_k> outbuf;
while(1) {
- strm_->avail_out = OUTBUF_LENGTH;
- strm_->next_out = outbuf;
+ 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));
}
- size_t produced = OUTBUF_LENGTH-strm_->avail_out;
+ size_t produced = outbuf.size() - strm_->avail_out;
out.append(&outbuf[0], &outbuf[produced]);
if(strm_->avail_out > 0) {
break;