diff options
author | David Benjamin <davidben@chromium.org> | 2015-03-23 00:22:08 +0300 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2015-04-01 02:03:54 +0300 |
commit | 1d77e56b29c0d519cf8eaa1fead1a12895f5cc54 (patch) | |
tree | 30c3866879e361d3bb1c31f2cb0fd9ffdad239ab /crypto/test | |
parent | 45fb1be33e6194aa8c7c414416b6cc657df660f4 (diff) |
Convert ssl_test to C++.
Change-Id: Ic8f3cd5c6a89e07bbae43b1599a01fedf119b081
Reviewed-on: https://boringssl-review.googlesource.com/4121
Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/test')
-rw-r--r-- | crypto/test/scoped_types.h | 12 | ||||
-rw-r--r-- | crypto/test/stl_compat.h | 8 |
2 files changed, 20 insertions, 0 deletions
diff --git a/crypto/test/scoped_types.h b/crypto/test/scoped_types.h index c9894b6b..63006219 100644 --- a/crypto/test/scoped_types.h +++ b/crypto/test/scoped_types.h @@ -15,9 +15,12 @@ #ifndef OPENSSL_HEADER_CRYPTO_TEST_SCOPED_TYPES_H #define OPENSSL_HEADER_CRYPTO_TEST_SCOPED_TYPES_H +#include <stdint.h> + #include <openssl/bio.h> #include <openssl/dh.h> #include <openssl/evp.h> +#include <openssl/mem.h> #include "stl_compat.h" @@ -29,6 +32,13 @@ struct OpenSSLDeleter { } }; +template<typename T> +struct OpenSSLFree { + void operator()(T *buf) { + OPENSSL_free(buf); + } +}; + template<typename T, void (*func)(T*)> using ScopedOpenSSLType = bssl::unique_ptr<T, OpenSSLDeleter<T, func>>; @@ -36,5 +46,7 @@ using ScopedBIO = ScopedOpenSSLType<BIO, BIO_vfree>; using ScopedDH = ScopedOpenSSLType<DH, DH_free>; using ScopedEVP_PKEY = ScopedOpenSSLType<EVP_PKEY, EVP_PKEY_free>; +using ScopedOpenSSLBytes = bssl::unique_ptr<uint8_t, OpenSSLFree<uint8_t>>; + #endif // OPENSSL_HEADER_CRYPTO_TEST_SCOPED_TYPES_H diff --git a/crypto/test/stl_compat.h b/crypto/test/stl_compat.h index 39ad86fe..9c45a982 100644 --- a/crypto/test/stl_compat.h +++ b/crypto/test/stl_compat.h @@ -17,6 +17,8 @@ #include <assert.h> +#include <vector> + // This header contains re-implementations of library functions from C++11. They // will be replaced with their standard counterparts once Chromium has C++11 @@ -24,6 +26,12 @@ namespace bssl { +// vector_data is a reimplementation of |std::vector::data| from C++11. +template <class T> +static T *vector_data(std::vector<T> *out) { + return out->empty() ? nullptr : &(*out)[0]; +} + // remove_reference is a reimplementation of |std::remove_reference| from C++11. template <class T> struct remove_reference { |