Use std::make_unique when possible

We've required C++14 for a while now. As we're mostly C with a little
C++, this is less helpful, but may as well avoid bare new where
possible.

Change-Id: Icf3386e3f3b6f2092bb0089ed874cc50985f1a40
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/61429
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
This commit is contained in:
David Benjamin
2023-07-04 12:48:02 -04:00
committed by Boringssl LUCI CQ
parent 417069f8b2
commit a36ac0a2e7
22 changed files with 63 additions and 64 deletions
+3 -3
View File
@@ -320,7 +320,7 @@ TEST(ChaChaTest, TestVector) {
for (size_t len = 0; len <= sizeof(kInput); len++) {
SCOPED_TRACE(len);
std::unique_ptr<uint8_t[]> buf(new uint8_t[len]);
auto buf = std::make_unique<uint8_t[]>(len);
CRYPTO_chacha_20(buf.get(), kInput, len, kKey, kNonce, kCounter);
EXPECT_EQ(Bytes(kOutput, len), Bytes(buf.get(), len));
@@ -336,7 +336,7 @@ TEST(ChaChaTest, CounterOverflow) {
for (size_t len = 0; len <= sizeof(kInput); len++) {
SCOPED_TRACE(len);
std::unique_ptr<uint8_t[]> buf(new uint8_t[len]);
auto buf = std::make_unique<uint8_t[]>(len);
CRYPTO_chacha_20(buf.get(), kInput, len, kKey, kNonce, kOverflowCounter);
EXPECT_EQ(Bytes(kOverflowOutput, len), Bytes(buf.get(), len));
@@ -354,7 +354,7 @@ TEST(ChaChaTest, ABI) {
static const uint32_t kCounterNonce[4] = {0};
std::unique_ptr<uint8_t[]> buf(new uint8_t[sizeof(kInput)]);
auto buf = std::make_unique<uint8_t[]>(sizeof(kInput));
for (size_t len = 0; len <= 32; len++) {
SCOPED_TRACE(len);
CHECK_ABI(ChaCha20_ctr32, buf.get(), kInput, len, key, kCounterNonce);
+1 -1
View File
@@ -821,7 +821,7 @@ TEST(ChaChaPoly1305Test, ABI) {
return;
}
std::unique_ptr<uint8_t[]> buf(new uint8_t[1024]);
auto buf = std::make_unique<uint8_t[]>(1024);
for (size_t len = 0; len <= 1024; len += 5) {
SCOPED_TRACE(len);
union chacha20_poly1305_open_data open_ctx = {};
+1 -1
View File
@@ -167,7 +167,7 @@ static void TestDigest(const DigestTestVector *test) {
for (size_t i = 0; i < test->repeat; i++) {
ASSERT_TRUE(EVP_DigestUpdate(ctx.get(), test->input, strlen(test->input)));
}
std::unique_ptr<uint8_t[]> digest(new uint8_t[EVP_MD_size(test->md.func())]);
auto digest = std::make_unique<uint8_t[]>(EVP_MD_size(test->md.func()));
unsigned digest_len;
ASSERT_TRUE(EVP_DigestFinal_ex(ctx.get(), digest.get(), &digest_len));
CompareDigest(test, digest.get(), digest_len);
+4 -4
View File
@@ -89,7 +89,7 @@ static void TestKeyWrap(FileTest *t) {
ASSERT_EQ(0, AES_set_encrypt_key(key.data(), 8 * key.size(), &aes_key));
// Test with implicit IV.
std::unique_ptr<uint8_t[]> buf(new uint8_t[ciphertext.size()]);
auto buf = std::make_unique<uint8_t[]>(ciphertext.size());
int len = AES_wrap_key(&aes_key, nullptr /* iv */, buf.get(),
plaintext.data(), plaintext.size());
ASSERT_GE(len, 0);
@@ -106,7 +106,7 @@ static void TestKeyWrap(FileTest *t) {
ASSERT_EQ(0, AES_set_decrypt_key(key.data(), 8 * key.size(), &aes_key));
// Test with implicit IV.
buf.reset(new uint8_t[plaintext.size()]);
buf = std::make_unique<uint8_t[]>(plaintext.size());
len = AES_unwrap_key(&aes_key, nullptr /* iv */, buf.get(), ciphertext.data(),
ciphertext.size());
ASSERT_GE(len, 0);
@@ -133,7 +133,7 @@ static void TestKeyWrapWithPadding(FileTest *t) {
// Test encryption.
AES_KEY aes_key;
ASSERT_EQ(0, AES_set_encrypt_key(key.data(), 8 * key.size(), &aes_key));
std::unique_ptr<uint8_t[]> buf(new uint8_t[plaintext.size() + 15]);
auto buf = std::make_unique<uint8_t[]>(plaintext.size() + 15);
size_t len;
ASSERT_TRUE(AES_wrap_key_padded(&aes_key, buf.get(), &len,
plaintext.size() + 15, plaintext.data(),
@@ -142,7 +142,7 @@ static void TestKeyWrapWithPadding(FileTest *t) {
// Test decryption
ASSERT_EQ(0, AES_set_decrypt_key(key.data(), 8 * key.size(), &aes_key));
buf.reset(new uint8_t[ciphertext.size() - 8]);
buf = std::make_unique<uint8_t[]>(ciphertext.size() - 8);
ASSERT_TRUE(AES_unwrap_key_padded(&aes_key, buf.get(), &len,
ciphertext.size() - 8, ciphertext.data(),
ciphertext.size()));
+14 -11
View File
@@ -458,8 +458,8 @@ static void TestSquare(BIGNUMFileTest *t, BN_CTX *ctx) {
SCOPED_TRACE(num_a);
size_t num_r = 2 * num_a;
// Use newly-allocated buffers so ASan will catch out-of-bounds writes.
std::unique_ptr<BN_ULONG[]> a_words(new BN_ULONG[num_a]),
r_words(new BN_ULONG[num_r]);
auto a_words = std::make_unique<BN_ULONG[]>(num_a);
auto r_words = std::make_unique<BN_ULONG[]>(num_r);
ASSERT_TRUE(bn_copy_words(a_words.get(), num_a, a.get()));
bn_mul_small(r_words.get(), num_r, a_words.get(), num_a, a_words.get(),
@@ -525,8 +525,9 @@ static void TestProduct(BIGNUMFileTest *t, BN_CTX *ctx) {
SCOPED_TRACE(num_b);
size_t num_r = num_a + num_b;
// Use newly-allocated buffers so ASan will catch out-of-bounds writes.
std::unique_ptr<BN_ULONG[]> a_words(new BN_ULONG[num_a]),
b_words(new BN_ULONG[num_b]), r_words(new BN_ULONG[num_r]);
auto a_words = std::make_unique<BN_ULONG[]>(num_a);
auto b_words = std::make_unique<BN_ULONG[]>(num_b);
auto r_words = std::make_unique<BN_ULONG[]>(num_r);
ASSERT_TRUE(bn_copy_words(a_words.get(), num_a, a.get()));
ASSERT_TRUE(bn_copy_words(b_words.get(), num_b, b.get()));
@@ -672,8 +673,9 @@ static void TestModMul(BIGNUMFileTest *t, BN_CTX *ctx) {
#if !defined(BORINGSSL_SHARED_LIBRARY)
size_t m_width = static_cast<size_t>(bn_minimal_width(m.get()));
if (m_width <= BN_SMALL_MAX_WORDS) {
std::unique_ptr<BN_ULONG[]> a_words(new BN_ULONG[m_width]),
b_words(new BN_ULONG[m_width]), r_words(new BN_ULONG[m_width]);
auto a_words = std::make_unique<BN_ULONG[]>(m_width);
auto b_words = std::make_unique<BN_ULONG[]>(m_width);
auto r_words = std::make_unique<BN_ULONG[]>(m_width);
ASSERT_TRUE(bn_copy_words(a_words.get(), m_width, a.get()));
ASSERT_TRUE(bn_copy_words(b_words.get(), m_width, b.get()));
bn_to_montgomery_small(a_words.get(), a_words.get(), m_width, mont.get());
@@ -691,7 +693,7 @@ static void TestModMul(BIGNUMFileTest *t, BN_CTX *ctx) {
// inputs. Test this by running |bn_from_montgomery_small| on the result
// of a product. Note |a_words| * |b_words| has an extra factor of R^2, so
// we must reduce twice.
std::unique_ptr<BN_ULONG[]> prod_words(new BN_ULONG[m_width * 2]);
auto prod_words = std::make_unique<BN_ULONG[]>(m_width * 2);
bn_mul_small(prod_words.get(), m_width * 2, a_words.get(), m_width,
b_words.get(), m_width);
bn_from_montgomery_small(r_words.get(), m_width, prod_words.get(),
@@ -752,8 +754,9 @@ static void TestModSquare(BIGNUMFileTest *t, BN_CTX *ctx) {
#if !defined(BORINGSSL_SHARED_LIBRARY)
size_t m_width = static_cast<size_t>(bn_minimal_width(m.get()));
if (m_width <= BN_SMALL_MAX_WORDS) {
std::unique_ptr<BN_ULONG[]> a_words(new BN_ULONG[m_width]),
a_copy_words(new BN_ULONG[m_width]), r_words(new BN_ULONG[m_width]);
auto a_words = std::make_unique<BN_ULONG[]>(m_width);
auto a_copy_words = std::make_unique<BN_ULONG[]>(m_width);
auto r_words = std::make_unique<BN_ULONG[]>(m_width);
ASSERT_TRUE(bn_copy_words(a_words.get(), m_width, a.get()));
bn_to_montgomery_small(a_words.get(), a_words.get(), m_width, mont.get());
bn_mod_mul_montgomery_small(r_words.get(), a_words.get(), a_words.get(),
@@ -815,8 +818,8 @@ static void TestModExp(BIGNUMFileTest *t, BN_CTX *ctx) {
bssl::UniquePtr<BN_MONT_CTX> mont(
BN_MONT_CTX_new_for_modulus(m.get(), ctx));
ASSERT_TRUE(mont.get());
std::unique_ptr<BN_ULONG[]> r_words(new BN_ULONG[m_width]),
a_words(new BN_ULONG[m_width]);
auto r_words = std::make_unique<BN_ULONG[]>(m_width);
auto a_words = std::make_unique<BN_ULONG[]>(m_width);
ASSERT_TRUE(bn_copy_words(a_words.get(), m_width, a.get()));
bn_to_montgomery_small(a_words.get(), a_words.get(), m_width, mont.get());
bn_mod_exp_mont_small(r_words.get(), a_words.get(), m_width, e->d,
+1 -1
View File
@@ -76,7 +76,7 @@ TEST(CTRDRBGTest, Large) {
CTR_DRBG_STATE drbg;
ASSERT_TRUE(CTR_DRBG_init(&drbg, kSeed, nullptr, 0));
std::unique_ptr<uint8_t[]> buf(new uint8_t[CTR_DRBG_MAX_GENERATE_LENGTH]);
auto buf = std::make_unique<uint8_t[]>(CTR_DRBG_MAX_GENERATE_LENGTH);
ASSERT_TRUE(CTR_DRBG_generate(&drbg, buf.get(), CTR_DRBG_MAX_GENERATE_LENGTH,
nullptr, 0));
+1 -1
View File
@@ -99,7 +99,7 @@ TEST(HMACTest, TestVectors) {
ASSERT_EQ(EVP_MD_size(digest), output.size());
// Test using the one-shot API.
std::unique_ptr<uint8_t[]> mac(new uint8_t[EVP_MD_size(digest)]);
auto mac = std::make_unique<uint8_t[]>(EVP_MD_size(digest));
unsigned mac_len;
ASSERT_TRUE(HMAC(digest, key.data(), key.size(), input.data(), input.size(),
mac.get(), &mac_len));
+1 -1
View File
@@ -36,7 +36,7 @@ DEFINE_LHASH_OF(char)
static std::unique_ptr<char[]> RandString(void) {
unsigned len = 1 + (rand() % 3);
std::unique_ptr<char[]> ret(new char[len + 1]);
auto ret = std::make_unique<char[]>(len + 1);
for (unsigned i = 0; i < len; i++) {
ret[i] = '0' + (rand() & 7);
+2 -3
View File
@@ -98,7 +98,7 @@ FileTest::ReadResult FileTest::ReadNext() {
ClearTest();
static const size_t kBufLen = 8192 * 4;
std::unique_ptr<char[]> buf(new char[kBufLen]);
auto buf = std::make_unique<char[]>(kBufLen);
bool in_instruction_block = false;
is_at_new_instruction_block_ = false;
@@ -409,8 +409,7 @@ int FileTestMain(FileTestFunc run_test, void *arg, const char *path) {
}
int FileTestMain(const FileTest::Options &opts) {
std::unique_ptr<FileLineReader> reader(
new FileLineReader(opts.path));
auto reader = std::make_unique<FileLineReader>(opts.path);
if (!reader->is_open()) {
fprintf(stderr, "Could not open file %s: %s.\n", opts.path,
strerror(errno));
+2 -3
View File
@@ -66,9 +66,8 @@ class StringLineReader : public FileTest::LineReader {
};
void FileTestGTest(const char *path, std::function<void(FileTest *)> run_test) {
std::unique_ptr<StringLineReader> reader(
new StringLineReader(GetTestData(path)));
FileTest t(std::move(reader), nullptr, false);
FileTest t(std::make_unique<StringLineReader>(GetTestData(path)), nullptr,
false);
while (true) {
switch (t.ReadNext()) {
+2 -2
View File
@@ -2335,7 +2335,7 @@ TEST(X509Test, TestFromBufferWithTrailingData) {
bssl::UniquePtr<uint8_t> data;
ASSERT_TRUE(PEMToDER(&data, &data_len, kRootCAPEM));
std::unique_ptr<uint8_t[]> trailing_data(new uint8_t[data_len + 1]);
auto trailing_data = std::make_unique<uint8_t[]>(data_len + 1);
OPENSSL_memcpy(trailing_data.get(), data.get(), data_len);
bssl::UniquePtr<CRYPTO_BUFFER> buf_trailing_data(
@@ -2438,7 +2438,7 @@ TEST(X509Test, TestFailedParseFromBuffer) {
bssl::UniquePtr<uint8_t> data;
ASSERT_TRUE(PEMToDER(&data, &data_len, kRootCAPEM));
std::unique_ptr<uint8_t[]> data_with_trailing_byte(new uint8_t[data_len + 1]);
auto data_with_trailing_byte = std::make_unique<uint8_t[]>(data_len + 1);
OPENSSL_memcpy(data_with_trailing_byte.get(), data.get(), data_len);
data_with_trailing_byte[data_len] = 0;
+2 -2
View File
@@ -87,7 +87,7 @@ TEST(CFBTest, TestVectors) {
SCOPED_TRACE(test_num);
const size_t input_len = sizeof(test.plaintext);
std::unique_ptr<uint8_t[]> out(new uint8_t[input_len]);
auto out = std::make_unique<uint8_t[]>(input_len);
for (size_t stride = 1; stride <= input_len; stride++) {
bssl::ScopedEVP_CIPHER_CTX ctx;
@@ -134,7 +134,7 @@ TEST(CFBTest, TestVectors) {
nullptr, test.key, test.iv));
}
std::unique_ptr<uint8_t[]> plaintext(new uint8_t[input_len]);
auto plaintext = std::make_unique<uint8_t[]>(input_len);
int num_bytes;
ASSERT_TRUE(EVP_DecryptUpdate(decrypt_ctx.get(), plaintext.get(),
&num_bytes, out.get(), input_len));
+1 -1
View File
@@ -90,7 +90,7 @@ TEST(RIPEMDTest, RunTest) {
}
static const size_t kLargeBufSize = 1000000;
std::unique_ptr<uint8_t[]> buf(new uint8_t[kLargeBufSize]);
auto buf = std::make_unique<uint8_t[]>(kLargeBufSize);
OPENSSL_memset(buf.get(), 'a', kLargeBufSize);
uint8_t digest[RIPEMD160_DIGEST_LENGTH];
RIPEMD160(buf.get(), kLargeBufSize, digest);
+2 -2
View File
@@ -3522,7 +3522,7 @@ static bool GetServerTicketTime(long *out, const SSL_SESSION *session) {
const uint8_t *ciphertext = ticket + 16 + 16;
size_t len = ticket_len - 16 - 16 - SHA256_DIGEST_LENGTH;
std::unique_ptr<uint8_t[]> plaintext(new uint8_t[len]);
auto plaintext = std::make_unique<uint8_t[]>(len);
#if defined(BORINGSSL_UNSAFE_FUZZER_MODE)
// Fuzzer-mode tickets are unencrypted.
@@ -6299,7 +6299,7 @@ class QUICMethodTest : public testing::Test {
SSL_set_connect_state(client_.get());
SSL_set_accept_state(server_.get());
transport_.reset(new MockQUICTransportPair);
transport_ = std::make_unique<MockQUICTransportPair>();
if (!ex_data_.Set(client_.get(), transport_->client()) ||
!ex_data_.Set(server_.get(), transport_->server())) {
return false;
+7 -7
View File
@@ -243,7 +243,7 @@ static int DoRead(SSL *ssl, uint8_t *out, size_t max_out) {
} while (RetryAsync(ssl, ret));
if (config->peek_then_read && ret > 0) {
std::unique_ptr<uint8_t[]> buf(new uint8_t[static_cast<size_t>(ret)]);
auto buf = std::make_unique<uint8_t[]>(static_cast<size_t>(ret));
// SSL_peek should synchronously return the same data.
int ret2 = SSL_peek(ssl, buf.get(), ret);
@@ -790,8 +790,8 @@ static bool DoConnection(bssl::UniquePtr<SSL_SESSION> *out_session,
SSL_CTX *ssl_ctx, const TestConfig *config,
const TestConfig *retry_config, bool is_resume,
SSL_SESSION *session, SettingsWriter *writer) {
bssl::UniquePtr<SSL> ssl = config->NewSSL(
ssl_ctx, session, std::unique_ptr<TestState>(new TestState));
bssl::UniquePtr<SSL> ssl =
config->NewSSL(ssl_ctx, session, std::make_unique<TestState>());
if (!ssl) {
return false;
}
@@ -858,8 +858,8 @@ static bool DoConnection(bssl::UniquePtr<SSL_SESSION> *out_session,
bio = std::move(async_scoped);
}
if (config->is_quic) {
GetTestState(ssl.get())->quic_transport.reset(
new MockQuicTransport(std::move(bio), ssl.get()));
GetTestState(ssl.get())->quic_transport =
std::make_unique<MockQuicTransport>(std::move(bio), ssl.get());
} else {
SSL_set_bio(ssl.get(), bio.get(), bio.get());
bio.release(); // SSL_set_bio takes ownership.
@@ -1144,7 +1144,7 @@ static bool DoExchange(bssl::UniquePtr<SSL_SESSION> *out_session,
// This mode writes a number of different record sizes in an attempt to
// trip up the CBC record splitting code.
static const size_t kBufLen = 32769;
std::unique_ptr<uint8_t[]> buf(new uint8_t[kBufLen]);
auto buf = std::make_unique<uint8_t[]>(kBufLen);
OPENSSL_memset(buf.get(), 0x42, kBufLen);
static const size_t kRecordSizes[] = {
0, 1, 255, 256, 257, 16383, 16384, 16385, 32767, 32768, 32769};
@@ -1194,7 +1194,7 @@ static bool DoExchange(bssl::UniquePtr<SSL_SESSION> *out_session,
if (config->read_size > 0) {
read_size = config->read_size;
}
std::unique_ptr<uint8_t[]> buf(new uint8_t[read_size]);
auto buf = std::make_unique<uint8_t[]>(read_size);
int n = DoRead(ssl, buf.get(), read_size);
int err = SSL_get_error(ssl, n);
+2 -3
View File
@@ -153,9 +153,8 @@ bool GenerateHandshakeHint(const TestConfig *config,
return false;
}
UniquePtr<SSL> ssl =
config->NewSSL(ctx.get(), /*session=*/nullptr,
std::unique_ptr<TestState>(new TestState));
UniquePtr<SSL> ssl = config->NewSSL(ctx.get(), /*session=*/nullptr,
std::make_unique<TestState>());
if (!ssl) {
fprintf(stderr, "Error creating SSL object in handshaker.\n");
ERR_print_errors_fp(stderr);
+3 -3
View File
@@ -139,7 +139,7 @@ Flag OptionalStringFlag(const char *name,
bool skip_handshaker = false) {
return Flag{name, true, skip_handshaker,
[=](TestConfig *config, const char *param) -> bool {
(config->*field).reset(new std::string(param));
(config->*field) = std::make_unique<std::string>(param);
return true;
}};
}
@@ -972,7 +972,7 @@ static bool HexDecode(std::string *out, const std::string &in) {
return false;
}
std::unique_ptr<uint8_t[]> buf(new uint8_t[in.size() / 2]);
auto buf = std::make_unique<uint8_t[]>(in.size() / 2);
for (size_t i = 0; i < in.size() / 2; i++) {
uint8_t high, low;
if (!OPENSSL_fromxdigit(&high, in[i * 2]) ||
@@ -1584,7 +1584,7 @@ bssl::UniquePtr<SSL_CTX> TestConfig::SetupCtx(SSL_CTX *old_ctx) const {
if (uncompressed_len != 2 + in_len) {
return 0;
}
std::unique_ptr<uint8_t[]> buf(new uint8_t[2 + in_len]);
auto buf = std::make_unique<uint8_t[]>(2 + in_len);
buf[0] = 0;
buf[1] = 0;
OPENSSL_memcpy(&buf[2], in, in_len);
+1 -1
View File
@@ -115,7 +115,7 @@ static bool SumFile(std::string *out_hex, const EVP_MD *md,
}
static const size_t kBufSize = 8192;
std::unique_ptr<uint8_t[]> buf(new uint8_t[kBufSize]);
auto buf = std::make_unique<uint8_t[]>(kBufSize);
bssl::ScopedEVP_MD_CTX ctx;
if (!EVP_DigestInit_ex(ctx.get(), md, NULL)) {
+1 -1
View File
@@ -72,7 +72,7 @@ bool DoPKCS12(const std::vector<std::string> &args) {
}
const size_t size = st.st_size;
std::unique_ptr<uint8_t[]> contents(new uint8_t[size]);
auto contents = std::make_unique<uint8_t[]>(size);
size_t off = 0;
while (off < size) {
size_t bytes_read;
+1 -1
View File
@@ -68,7 +68,7 @@ bool Sign(const std::vector<std::string> &args) {
}
size_t sig_len = EVP_PKEY_size(key.get());
std::unique_ptr<uint8_t[]> sig(new uint8_t[sig_len]);
auto sig = std::make_unique<uint8_t[]>(sig_len);
if (!EVP_DigestSign(ctx.get(), sig.get(), &sig_len, data.data(),
data.size())) {
return false;
+10 -11
View File
@@ -476,22 +476,21 @@ static bool SpeedAEADChunk(const EVP_AEAD *aead, std::string name,
const size_t nonce_len = EVP_AEAD_nonce_length(aead);
const size_t overhead_len = EVP_AEAD_max_overhead(aead);
std::unique_ptr<uint8_t[]> key(new uint8_t[key_len]);
auto key = std::make_unique<uint8_t[]>(key_len);
OPENSSL_memset(key.get(), 0, key_len);
std::unique_ptr<uint8_t[]> nonce(new uint8_t[nonce_len]);
auto nonce = std::make_unique<uint8_t[]>(nonce_len);
OPENSSL_memset(nonce.get(), 0, nonce_len);
std::unique_ptr<uint8_t[]> in_storage(new uint8_t[chunk_len + kAlignment]);
auto in_storage = std::make_unique<uint8_t[]>(chunk_len + kAlignment);
// N.B. for EVP_AEAD_CTX_seal_scatter the input and output buffers may be the
// same size. However, in the direction == evp_aead_open case we still use
// non-scattering seal, hence we add overhead_len to the size of this buffer.
std::unique_ptr<uint8_t[]> out_storage(
new uint8_t[chunk_len + overhead_len + kAlignment]);
std::unique_ptr<uint8_t[]> in2_storage(
new uint8_t[chunk_len + overhead_len + kAlignment]);
std::unique_ptr<uint8_t[]> ad(new uint8_t[ad_len]);
auto out_storage =
std::make_unique<uint8_t[]>(chunk_len + overhead_len + kAlignment);
auto in2_storage =
std::make_unique<uint8_t[]>(chunk_len + overhead_len + kAlignment);
auto ad = std::make_unique<uint8_t[]>(ad_len);
OPENSSL_memset(ad.get(), 0, ad_len);
std::unique_ptr<uint8_t[]> tag_storage(
new uint8_t[overhead_len + kAlignment]);
auto tag_storage = std::make_unique<uint8_t[]>(overhead_len + kAlignment);
uint8_t *const in =
@@ -760,7 +759,7 @@ static bool SpeedECDHCurve(const std::string &name, int nid,
if (peer_value_len == 0) {
return false;
}
std::unique_ptr<uint8_t[]> peer_value(new uint8_t[peer_value_len]);
auto peer_value = std::make_unique<uint8_t[]>(peer_value_len);
peer_value_len = EC_POINT_point2oct(
EC_KEY_get0_group(peer_key.get()), EC_KEY_get0_public_key(peer_key.get()),
POINT_CONVERSION_UNCOMPRESSED, peer_value.get(), peer_value_len, nullptr);
@@ -75,7 +75,7 @@ class RequestBufferImpl : public RequestBuffer {
// static
std::unique_ptr<RequestBuffer> RequestBuffer::New() {
return std::unique_ptr<RequestBuffer>(new RequestBufferImpl);
return std::make_unique<RequestBufferImpl>();
}
static bool ReadAll(int fd, void *in_data, size_t data_len) {