浏览代码

Merge pull request #1064 from kwkam/syntax

replace some lines with make_unique
Tatsuhiro Tsujikawa 8 年之前
父节点
当前提交
983e222c62
共有 3 个文件被更改,包括 12 次插入12 次删除
  1. 2 2
      src/HttpHeaderProcessor.cc
  2. 4 4
      src/bignum.h
  3. 6 6
      src/crypto_hash.cc

+ 2 - 2
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();
 }
 

+ 4 - 4
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();

+ 6 - 6
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");