summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2017-11-08 21:29:26 +0900
committerGitHub <noreply@github.com>2017-11-08 21:29:26 +0900
commit983e222c62085483bfcf910c4886669d00873a7f (patch)
treebd400d6ce0d8d7587d568194c9404573e06e7567
parent3c6a70c566e19354fa8c6dbe6374471666cce72d (diff)
parentdd60bba5adce136582626a8fb200fef7d630e241 (diff)
Merge pull request #1064 from kwkam/syntax
replace some lines with make_unique
-rw-r--r--src/HttpHeaderProcessor.cc4
-rw-r--r--src/bignum.h8
-rw-r--r--src/crypto_hash.cc12
3 files changed, 12 insertions, 12 deletions
diff --git a/src/HttpHeaderProcessor.cc b/src/HttpHeaderProcessor.cc
index 9b40b2e7..53f061e6 100644
--- a/src/HttpHeaderProcessor.cc
+++ b/src/HttpHeaderProcessor.cc
@@ -79,7 +79,7 @@ HttpHeaderProcessor::HttpHeaderProcessor(ParserMode mode)
state_(mode == CLIENT_PARSER ? PREV_RES_VERSION : PREV_METHOD),
lastBytesProcessed_(0),
lastFieldHdKey_(HttpHeader::MAX_INTERESTING_HEADER),
- result_(new HttpHeader())
+ result_(make_unique<HttpHeader>())
{
}
@@ -481,7 +481,7 @@ void HttpHeaderProcessor::clear()
buf_.clear();
lastFieldName_.clear();
lastFieldHdKey_ = HttpHeader::MAX_INTERESTING_HEADER;
- result_.reset(new HttpHeader());
+ result_ = make_unique<HttpHeader>();
headers_.clear();
}
diff --git a/src/bignum.h b/src/bignum.h
index 33e631ad..e59ab6bb 100644
--- a/src/bignum.h
+++ b/src/bignum.h
@@ -31,17 +31,17 @@ private:
std::unique_ptr<char_t[]> buf_;
public:
- inline ulong() : buf_(new char_t[dim]()) {}
- inline ulong(size_t t) : buf_(new char_t[dim]())
+ inline ulong() : buf_(make_unique<char_t[]>(dim)) {}
+ inline ulong(size_t t) : buf_(make_unique<char_t[]>(dim))
{
memcpy(buf_.get(), (char_t*)&t, sizeof(t));
}
- inline ulong(const ulong<dim>& rhs) : buf_(new char_t[dim]())
+ inline ulong(const ulong<dim>& rhs) : buf_(make_unique<char_t[]>(dim))
{
memcpy(buf_.get(), rhs.buf_.get(), dim);
}
explicit inline ulong(const char_t* data, size_t size)
- : buf_(new char_t[dim]())
+ : buf_(make_unique<char_t[]>(dim))
{
if (size > dim) {
throw std::bad_alloc();
diff --git a/src/crypto_hash.cc b/src/crypto_hash.cc
index f6fb6d99..5ea03341 100644
--- a/src/crypto_hash.cc
+++ b/src/crypto_hash.cc
@@ -1055,22 +1055,22 @@ std::unique_ptr<Algorithm> crypto::hash::create(Algorithms algo)
{
switch (algo) {
case algoMD5:
- return std::unique_ptr<MD5>(new MD5());
+ return make_unique<MD5>();
case algoSHA1:
- return std::unique_ptr<SHA1>(new SHA1());
+ return make_unique<SHA1>();
case algoSHA224:
- return std::unique_ptr<SHA224>(new SHA224());
+ return make_unique<SHA224>();
case algoSHA256:
- return std::unique_ptr<SHA256>(new SHA256());
+ return make_unique<SHA256>();
case algoSHA384:
- return std::unique_ptr<SHA384>(new SHA384());
+ return make_unique<SHA384>();
case algoSHA512:
- return std::unique_ptr<SHA512>(new SHA512());
+ return make_unique<SHA512>();
default:
throw std::domain_error("Invalid hash algorithm");