Use make_unique_noinit

fix #605
This commit is contained in:
Vinnie Falco
2017-07-08 20:45:35 -07:00
parent f34d4f7204
commit 69b61656dd
5 changed files with 14 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ Version 78:
* Add span
* Documentation work
* Use make_unique_noinit
HTTP:

View File

@@ -15,6 +15,7 @@
#include <beast/http/error.hpp>
#include <beast/http/rfc7230.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/make_unique.hpp>
#include <algorithm>
#include <utility>
@@ -120,7 +121,7 @@ put(ConstBufferSequence const& buffers,
if(size > buf_len_)
{
// reallocate
buf_.reset(new char[size]);
buf_ = boost::make_unique_noinit<char[]>(size);
buf_len_ = size;
}
// flatten

View File

@@ -24,6 +24,7 @@
#include <beast/core/detail/type_traits.hpp>
#include <boost/assert.hpp>
#include <boost/endian/buffers.hpp>
#include <boost/make_unique.hpp>
#include <boost/throw_exception.hpp>
#include <algorithm>
#include <memory>
@@ -569,7 +570,8 @@ rd_begin()
if(! rd_.buf || rd_.buf_size != rd_buf_size_)
{
rd_.buf_size = rd_buf_size_;
rd_.buf.reset(new std::uint8_t[rd_.buf_size]);
rd_.buf = boost::make_unique_noinit<
std::uint8_t[]>(rd_.buf_size);
}
}
}
@@ -589,7 +591,8 @@ wr_begin()
if(! wr_.buf || wr_.buf_size != wr_buf_size_)
{
wr_.buf_size = wr_buf_size_;
wr_.buf.reset(new std::uint8_t[wr_.buf_size]);
wr_.buf = boost::make_unique_noinit<
std::uint8_t[]>(wr_.buf_size);
}
}
else

View File

@@ -40,6 +40,7 @@
#include <beast/core/detail/type_traits.hpp>
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/make_unique.hpp>
#include <boost/optional.hpp>
#include <boost/throw_exception.hpp>
#include <cstdint>
@@ -1281,7 +1282,8 @@ init()
if(! buf_ || buf_size_ != needed)
{
buf_.reset(new std::uint8_t[needed]);
buf_ = boost::make_unique_noinit<
std::uint8_t[]>(needed);
buf_size_ = needed;
}

View File

@@ -36,6 +36,7 @@
#define BEAST_ZLIB_DETAIL_WINDOW_HPP
#include <boost/assert.hpp>
#include <boost/make_unique.hpp>
#include <cstdint>
#include <cstring>
#include <memory>
@@ -126,7 +127,8 @@ window::
write(std::uint8_t const* in, std::size_t n)
{
if(! p_)
p_.reset(new std::uint8_t[capacity_]);
p_ = boost::make_unique<
std::uint8_t[]>(capacity_);
if(n >= capacity_)
{
i_ = 0;