mirror of https://github.com/aria2/aria2
replace some lines with make_unique
parent
3c6a70c566
commit
dd60bba5ad
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue