Replace Scoped* heap types with bssl::UniquePtr.
Unlike the Scoped* types, bssl::UniquePtr is available to C++ users, and
offered for a large variety of types. The 'extern "C++"' trick is used
to make the C++ bits digestible to C callers that wrap header files in
'extern "C"'.
Change-Id: Ifbca4c2997d6628e33028c7d7620c72aff0f862e
Reviewed-on: https://boringssl-review.googlesource.com/10521
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
diff --git a/crypto/bio/bio_test.cc b/crypto/bio/bio_test.cc
index d7be884..cbc4fde 100644
--- a/crypto/bio/bio_test.cc
+++ b/crypto/bio/bio_test.cc
@@ -41,7 +41,6 @@
#include <algorithm>
#include "../internal.h"
-#include "../test/scoped_types.h"
#if !defined(OPENSSL_WINDOWS)
@@ -104,7 +103,7 @@
char hostname[80];
BIO_snprintf(hostname, sizeof(hostname), "%s:%d", "127.0.0.1",
ntohs(sin.sin_port));
- ScopedBIO bio(BIO_new_connect(hostname));
+ bssl::UniquePtr<BIO> bio(BIO_new_connect(hostname));
if (!bio) {
fprintf(stderr, "BIO_new_connect failed.\n");
return false;
@@ -216,8 +215,8 @@
if (!BIO_new_bio_pair(&bio1, kBufferSize, &bio2, kBufferSize)) {
return false;
}
- ScopedBIO bio1_scoper(bio1);
- ScopedBIO bio2_scoper(bio2);
+ bssl::UniquePtr<BIO> bio1_scoper(bio1);
+ bssl::UniquePtr<BIO> bio2_scoper(bio2);
total_write += BioWriteZeroCopyWrapper(
bio1, bio1_application_send_buffer, kLengths[i]);
@@ -287,7 +286,7 @@
// 256 (the size of the buffer) to ensure edge cases are correct.
static const size_t kLengths[] = { 5, 250, 251, 252, 253, 254, 1023 };
- ScopedBIO bio(BIO_new(BIO_s_mem()));
+ bssl::UniquePtr<BIO> bio(BIO_new(BIO_s_mem()));
if (!bio) {
fprintf(stderr, "BIO_new failed\n");
return false;
@@ -331,7 +330,7 @@
static bool ReadASN1(bool should_succeed, const uint8_t *data, size_t data_len,
size_t expected_len, size_t max_len) {
- ScopedBIO bio(BIO_new_mem_buf(data, data_len));
+ bssl::UniquePtr<BIO> bio(BIO_new_mem_buf(data, data_len));
uint8_t *out;
size_t out_len;
@@ -339,7 +338,7 @@
if (!ok) {
out = nullptr;
}
- ScopedOpenSSLBytes out_storage(out);
+ bssl::UniquePtr<uint8_t> out_storage(out);
if (should_succeed != (ok == 1)) {
return false;
@@ -369,7 +368,7 @@
static const size_t kLargePayloadLen = 8000;
static const uint8_t kLargePrefix[] = {0x30, 0x82, kLargePayloadLen >> 8,
kLargePayloadLen & 0xff};
- ScopedOpenSSLBytes large(reinterpret_cast<uint8_t *>(
+ bssl::UniquePtr<uint8_t> large(reinterpret_cast<uint8_t *>(
OPENSSL_malloc(sizeof(kLargePrefix) + kLargePayloadLen)));
if (!large) {
return false;