/src/boringssl/crypto/mem_internal.h
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright 2025 The BoringSSL Authors |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | // you may not use this file except in compliance with the License. |
5 | | // You may obtain a copy of the License at |
6 | | // |
7 | | // https://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software |
10 | | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | // See the License for the specific language governing permissions and |
13 | | // limitations under the License. |
14 | | |
15 | | #ifndef OPENSSL_HEADER_CRYPTO_MEM_INTERNAL_H |
16 | | #define OPENSSL_HEADER_CRYPTO_MEM_INTERNAL_H |
17 | | |
18 | | #include <openssl/mem.h> |
19 | | |
20 | | #include <algorithm> |
21 | | #include <memory> |
22 | | #include <type_traits> |
23 | | #include <utility> |
24 | | |
25 | | #include <openssl/err.h> |
26 | | #include <openssl/span.h> |
27 | | |
28 | | |
29 | | BSSL_NAMESPACE_BEGIN |
30 | | |
31 | | // Internal allocation-dependent functions. |
32 | | // |
33 | | // This header is separate from crypto/internal.h because there are some files |
34 | | // which must avoid |OPENSSL_malloc|, to avoid a circular dependency, but |
35 | | // need other support routines in crypto/internal.h. (See |
36 | | // |_BORINGSSL_PROHIBIT_OPENSSL_MALLOC|.) |
37 | | |
38 | | |
39 | | // Memory allocation. |
40 | | |
41 | | // New behaves like |new| but uses |OPENSSL_malloc| for memory allocation. It |
42 | | // returns nullptr on allocation error. It only implements single-object |
43 | | // allocation and not new T[n]. |
44 | | // |
45 | | // Note: unlike |new|, this does not support non-public constructors. |
46 | | template <typename T, typename... Args> |
47 | 2.42M | T *New(Args &&...args) { |
48 | 2.42M | void *t = OPENSSL_malloc(sizeof(T)); |
49 | 2.42M | if (t == nullptr) { |
50 | 0 | return nullptr; |
51 | 0 | } |
52 | 2.42M | return new (t) T(std::forward<Args>(args)...); |
53 | 2.42M | } Unexecuted instantiation: bssl::ECHConfig* bssl::New<bssl::ECHConfig, bssl::ECHConfig>(bssl::ECHConfig&&) ssl_ech_keys_st* bssl::New<ssl_ech_keys_st>() Line | Count | Source | 47 | 13.6k | T *New(Args &&...args) { | 48 | 13.6k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 13.6k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 13.6k | return new (t) T(std::forward<Args>(args)...); | 53 | 13.6k | } |
bssl::ECHServerConfig* bssl::New<bssl::ECHServerConfig>() Line | Count | Source | 47 | 11.8k | T *New(Args &&...args) { | 48 | 11.8k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 11.8k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 11.8k | return new (t) T(std::forward<Args>(args)...); | 53 | 11.8k | } |
bssl::SSLPAKEShare* bssl::New<bssl::SSLPAKEShare>() Line | Count | Source | 47 | 11 | T *New(Args &&...args) { | 48 | 11 | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 11 | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 11 | return new (t) T(std::forward<Args>(args)...); | 53 | 11 | } |
Unexecuted instantiation: bssl::spake2plus::Prover* bssl::New<bssl::spake2plus::Prover>() bssl::SSLCipherPreferenceList* bssl::New<bssl::SSLCipherPreferenceList>() Line | Count | Source | 47 | 17.7k | T *New(Args &&...args) { | 48 | 17.7k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 17.7k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 17.7k | return new (t) T(std::forward<Args>(args)...); | 53 | 17.7k | } |
bssl::SSL_HANDSHAKE_HINTS* bssl::New<bssl::SSL_HANDSHAKE_HINTS>() Line | Count | Source | 47 | 80.8k | T *New(Args &&...args) { | 48 | 80.8k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 80.8k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 80.8k | return new (t) T(std::forward<Args>(args)...); | 53 | 80.8k | } |
bssl::SSL_HANDSHAKE* bssl::New<bssl::SSL_HANDSHAKE, ssl_st*&>(ssl_st*&) Line | Count | Source | 47 | 170k | T *New(Args &&...args) { | 48 | 170k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 170k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 170k | return new (t) T(std::forward<Args>(args)...); | 53 | 170k | } |
bssl::SSLAEADContext* bssl::New<bssl::SSLAEADContext, decltype(nullptr)>(decltype(nullptr)&&) Line | Count | Source | 47 | 243k | T *New(Args &&...args) { | 48 | 243k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 243k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 243k | return new (t) T(std::forward<Args>(args)...); | 53 | 243k | } |
bssl::SSLAEADContext* bssl::New<bssl::SSLAEADContext, ssl_cipher_st const*&>(ssl_cipher_st const*&) Line | Count | Source | 47 | 159k | T *New(Args &&...args) { | 48 | 159k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 159k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 159k | return new (t) T(std::forward<Args>(args)...); | 53 | 159k | } |
ssl_credential_st* bssl::New<ssl_credential_st, bssl::SSLCredentialType>(bssl::SSLCredentialType&&) Line | Count | Source | 47 | 126k | T *New(Args &&...args) { | 48 | 126k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 126k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 126k | return new (t) T(std::forward<Args>(args)...); | 53 | 126k | } |
bssl::CERT* bssl::New<bssl::CERT, bssl::SSL_X509_METHOD const*&>(bssl::SSL_X509_METHOD const*&) Line | Count | Source | 47 | 121k | T *New(Args &&...args) { | 48 | 121k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 121k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 121k | return new (t) T(std::forward<Args>(args)...); | 53 | 121k | } |
Unexecuted instantiation: ssl_credential_st* bssl::New<ssl_credential_st, bssl::SSLCredentialType&>(bssl::SSLCredentialType&) ssl_credential_st* bssl::New<ssl_credential_st, bssl::SSLCredentialType const&>(bssl::SSLCredentialType const&) Line | Count | Source | 47 | 121k | T *New(Args &&...args) { | 48 | 121k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 121k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 121k | return new (t) T(std::forward<Args>(args)...); | 53 | 121k | } |
ssl_key_share.cc:bssl::(anonymous namespace)::ECKeyShare* bssl::New<bssl::(anonymous namespace)::ECKeyShare, ec_group_st const*, int>(ec_group_st const*&&, int&&) Line | Count | Source | 47 | 32.0k | T *New(Args &&...args) { | 48 | 32.0k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 32.0k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 32.0k | return new (t) T(std::forward<Args>(args)...); | 53 | 32.0k | } |
ssl_key_share.cc:bssl::(anonymous namespace)::X25519KeyShare* bssl::New<bssl::(anonymous namespace)::X25519KeyShare>() Line | Count | Source | 47 | 88.2k | T *New(Args &&...args) { | 48 | 88.2k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 88.2k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 88.2k | return new (t) T(std::forward<Args>(args)...); | 53 | 88.2k | } |
ssl_key_share.cc:bssl::(anonymous namespace)::X25519Kyber768KeyShare* bssl::New<bssl::(anonymous namespace)::X25519Kyber768KeyShare>() Line | Count | Source | 47 | 215 | T *New(Args &&...args) { | 48 | 215 | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 215 | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 215 | return new (t) T(std::forward<Args>(args)...); | 53 | 215 | } |
ssl_key_share.cc:bssl::(anonymous namespace)::X25519MLKEM768KeyShare* bssl::New<bssl::(anonymous namespace)::X25519MLKEM768KeyShare>() Line | Count | Source | 47 | 63.3k | T *New(Args &&...args) { | 48 | 63.3k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 63.3k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 63.3k | return new (t) T(std::forward<Args>(args)...); | 53 | 63.3k | } |
ssl_ctx_st* bssl::New<ssl_ctx_st, ssl_method_st const*&>(ssl_method_st const*&) Line | Count | Source | 47 | 4.87k | T *New(Args &&...args) { | 48 | 4.87k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 4.87k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 4.87k | return new (t) T(std::forward<Args>(args)...); | 53 | 4.87k | } |
bssl::CERT* bssl::New<bssl::CERT, bssl::SSL_X509_METHOD const* const&>(bssl::SSL_X509_METHOD const* const&) Line | Count | Source | 47 | 4.87k | T *New(Args &&...args) { | 48 | 4.87k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 4.87k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 4.87k | return new (t) T(std::forward<Args>(args)...); | 53 | 4.87k | } |
ssl_st* bssl::New<ssl_st, ssl_ctx_st*&>(ssl_ctx_st*&) Line | Count | Source | 47 | 121k | T *New(Args &&...args) { | 48 | 121k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 121k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 121k | return new (t) T(std::forward<Args>(args)...); | 53 | 121k | } |
bssl::SSL_CONFIG* bssl::New<bssl::SSL_CONFIG, ssl_st*>(ssl_st*&&) Line | Count | Source | 47 | 121k | T *New(Args &&...args) { | 48 | 121k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 121k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 121k | return new (t) T(std::forward<Args>(args)...); | 53 | 121k | } |
bssl::TicketKey* bssl::New<bssl::TicketKey>() Line | Count | Source | 47 | 392 | T *New(Args &&...args) { | 48 | 392 | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 392 | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 392 | return new (t) T(std::forward<Args>(args)...); | 53 | 392 | } |
ssl_session_st* bssl::New<ssl_session_st, bssl::SSL_X509_METHOD const*&>(bssl::SSL_X509_METHOD const*&) Line | Count | Source | 47 | 271k | T *New(Args &&...args) { | 48 | 271k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 271k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 271k | return new (t) T(std::forward<Args>(args)...); | 53 | 271k | } |
tls13_enc.cc:bssl::(anonymous namespace)::NullRecordNumberEncrypter* bssl::New<bssl::(anonymous namespace)::NullRecordNumberEncrypter>() Line | Count | Source | 47 | 46.7k | T *New(Args &&...args) { | 48 | 46.7k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 46.7k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 46.7k | return new (t) T(std::forward<Args>(args)...); | 53 | 46.7k | } |
Unexecuted instantiation: tls13_enc.cc:bssl::(anonymous namespace)::AES128RecordNumberEncrypter* bssl::New<bssl::(anonymous namespace)::AES128RecordNumberEncrypter>() Unexecuted instantiation: tls13_enc.cc:bssl::(anonymous namespace)::AES256RecordNumberEncrypter* bssl::New<bssl::(anonymous namespace)::AES256RecordNumberEncrypter>() Unexecuted instantiation: tls13_enc.cc:bssl::(anonymous namespace)::ChaChaRecordNumberEncrypter* bssl::New<bssl::(anonymous namespace)::ChaChaRecordNumberEncrypter>() Unexecuted instantiation: bssl::spake2plus::Verifier* bssl::New<bssl::spake2plus::Verifier>() bssl::DTLSIncomingMessage* bssl::New<bssl::DTLSIncomingMessage>() Line | Count | Source | 47 | 55.1k | T *New(Args &&...args) { | 48 | 55.1k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 55.1k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 55.1k | return new (t) T(std::forward<Args>(args)...); | 53 | 55.1k | } |
bssl::MRUQueue<bssl::DTLSSentRecord, 32ul>* bssl::New<bssl::MRUQueue<bssl::DTLSSentRecord, 32ul>>() Line | Count | Source | 47 | 10.6k | T *New(Args &&...args) { | 48 | 10.6k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 10.6k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 10.6k | return new (t) T(std::forward<Args>(args)...); | 53 | 10.6k | } |
bssl::DTLS1_STATE* bssl::New<bssl::DTLS1_STATE>() Line | Count | Source | 47 | 41.1k | T *New(Args &&...args) { | 48 | 41.1k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 41.1k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 41.1k | return new (t) T(std::forward<Args>(args)...); | 53 | 41.1k | } |
bssl::DTLSPrevReadEpoch* bssl::New<bssl::DTLSPrevReadEpoch>() Line | Count | Source | 47 | 36.6k | T *New(Args &&...args) { | 48 | 36.6k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 36.6k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 36.6k | return new (t) T(std::forward<Args>(args)...); | 53 | 36.6k | } |
bssl::SSL3_STATE* bssl::New<bssl::SSL3_STATE>() Line | Count | Source | 47 | 121k | T *New(Args &&...args) { | 48 | 121k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 121k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 121k | return new (t) T(std::forward<Args>(args)...); | 53 | 121k | } |
bignum_ctx* bssl::New<bignum_ctx>() Line | Count | Source | 47 | 118k | T *New(Args &&...args) { | 48 | 118k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 118k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 118k | return new (t) T(std::forward<Args>(args)...); | 53 | 118k | } |
evp_pkey_ctx_st* bssl::New<evp_pkey_ctx_st>() Line | Count | Source | 47 | 175k | T *New(Args &&...args) { | 48 | 175k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 175k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 175k | return new (t) T(std::forward<Args>(args)...); | 53 | 175k | } |
bssl::DTLSReadEpoch* bssl::New<bssl::DTLSReadEpoch, bssl::DTLSReadEpoch>(bssl::DTLSReadEpoch&&) Line | Count | Source | 47 | 39.1k | T *New(Args &&...args) { | 48 | 39.1k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 39.1k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 39.1k | return new (t) T(std::forward<Args>(args)...); | 53 | 39.1k | } |
bssl::DTLSWriteEpoch* bssl::New<bssl::DTLSWriteEpoch, bssl::DTLSWriteEpoch>(bssl::DTLSWriteEpoch&&) Line | Count | Source | 47 | 8.26k | T *New(Args &&...args) { | 48 | 8.26k | void *t = OPENSSL_malloc(sizeof(T)); | 49 | 8.26k | if (t == nullptr) { | 50 | 0 | return nullptr; | 51 | 0 | } | 52 | 8.26k | return new (t) T(std::forward<Args>(args)...); | 53 | 8.26k | } |
|
54 | | |
55 | | // Delete behaves like |delete| but uses |OPENSSL_free| to release memory. |
56 | | // |
57 | | // Note: unlike |delete| this does not support non-public destructors. |
58 | | template <typename T> |
59 | 1.90M | void Delete(T *t) { |
60 | 1.90M | if (t != nullptr) { |
61 | 1.89M | t->~T(); |
62 | 1.89M | OPENSSL_free(t); |
63 | 1.89M | } |
64 | 1.90M | } Unexecuted instantiation: void bssl::Delete<bssl::ECHConfig>(bssl::ECHConfig*) void bssl::Delete<bssl::ECHServerConfig>(bssl::ECHServerConfig*) Line | Count | Source | 59 | 11.8k | void Delete(T *t) { | 60 | 11.8k | if (t != nullptr) { | 61 | 11.8k | t->~T(); | 62 | 11.8k | OPENSSL_free(t); | 63 | 11.8k | } | 64 | 11.8k | } |
void bssl::Delete<bssl::SSLPAKEShare>(bssl::SSLPAKEShare*) Line | Count | Source | 59 | 11 | void Delete(T *t) { | 60 | 11 | if (t != nullptr) { | 61 | 11 | t->~T(); | 62 | 11 | OPENSSL_free(t); | 63 | 11 | } | 64 | 11 | } |
void bssl::Delete<bssl::SSLKeyShare>(bssl::SSLKeyShare*) Line | Count | Source | 59 | 183k | void Delete(T *t) { | 60 | 183k | if (t != nullptr) { | 61 | 183k | t->~T(); | 62 | 183k | OPENSSL_free(t); | 63 | 183k | } | 64 | 183k | } |
Unexecuted instantiation: void bssl::Delete<bssl::spake2plus::Prover>(bssl::spake2plus::Prover*) void bssl::Delete<bssl::SSLCipherPreferenceList>(bssl::SSLCipherPreferenceList*) Line | Count | Source | 59 | 17.7k | void Delete(T *t) { | 60 | 17.7k | if (t != nullptr) { | 61 | 17.7k | t->~T(); | 62 | 17.7k | OPENSSL_free(t); | 63 | 17.7k | } | 64 | 17.7k | } |
void bssl::Delete<bssl::SSL_HANDSHAKE>(bssl::SSL_HANDSHAKE*) Line | Count | Source | 59 | 170k | void Delete(T *t) { | 60 | 170k | if (t != nullptr) { | 61 | 170k | t->~T(); | 62 | 170k | OPENSSL_free(t); | 63 | 170k | } | 64 | 170k | } |
void bssl::Delete<bssl::SSL_HANDSHAKE_HINTS>(bssl::SSL_HANDSHAKE_HINTS*) Line | Count | Source | 59 | 80.8k | void Delete(T *t) { | 60 | 80.8k | if (t != nullptr) { | 61 | 80.8k | t->~T(); | 62 | 80.8k | OPENSSL_free(t); | 63 | 80.8k | } | 64 | 80.8k | } |
Unexecuted instantiation: void bssl::Delete<bssl::spake2plus::Verifier>(bssl::spake2plus::Verifier*) void bssl::Delete<bssl::SSLAEADContext>(bssl::SSLAEADContext*) Line | Count | Source | 59 | 402k | void Delete(T *t) { | 60 | 402k | if (t != nullptr) { | 61 | 402k | t->~T(); | 62 | 402k | OPENSSL_free(t); | 63 | 402k | } | 64 | 402k | } |
void bssl::Delete<bssl::CERT>(bssl::CERT*) Line | Count | Source | 59 | 126k | void Delete(T *t) { | 60 | 126k | if (t != nullptr) { | 61 | 126k | t->~T(); | 62 | 126k | OPENSSL_free(t); | 63 | 126k | } | 64 | 126k | } |
Unexecuted instantiation: ssl_key_share.cc:void bssl::Delete<bssl::(anonymous namespace)::ECKeyShare>(bssl::(anonymous namespace)::ECKeyShare*) Unexecuted instantiation: ssl_key_share.cc:void bssl::Delete<bssl::(anonymous namespace)::X25519KeyShare>(bssl::(anonymous namespace)::X25519KeyShare*) Unexecuted instantiation: ssl_key_share.cc:void bssl::Delete<bssl::(anonymous namespace)::X25519Kyber768KeyShare>(bssl::(anonymous namespace)::X25519Kyber768KeyShare*) Unexecuted instantiation: ssl_key_share.cc:void bssl::Delete<bssl::(anonymous namespace)::X25519MLKEM768KeyShare>(bssl::(anonymous namespace)::X25519MLKEM768KeyShare*) void bssl::Delete<bssl::SSL_CONFIG>(bssl::SSL_CONFIG*) Line | Count | Source | 59 | 121k | void Delete(T *t) { | 60 | 121k | if (t != nullptr) { | 61 | 121k | t->~T(); | 62 | 121k | OPENSSL_free(t); | 63 | 121k | } | 64 | 121k | } |
void bssl::Delete<ssl_st>(ssl_st*) Line | Count | Source | 59 | 121k | void Delete(T *t) { | 60 | 121k | if (t != nullptr) { | 61 | 121k | t->~T(); | 62 | 121k | OPENSSL_free(t); | 63 | 121k | } | 64 | 121k | } |
void bssl::Delete<bssl::TicketKey>(bssl::TicketKey*) Line | Count | Source | 59 | 389 | void Delete(T *t) { | 60 | 389 | if (t != nullptr) { | 61 | 389 | t->~T(); | 62 | 389 | OPENSSL_free(t); | 63 | 389 | } | 64 | 389 | } |
void bssl::Delete<bssl::RecordNumberEncrypter>(bssl::RecordNumberEncrypter*) Line | Count | Source | 59 | 46.7k | void Delete(T *t) { | 60 | 46.7k | if (t != nullptr) { | 61 | 46.7k | t->~T(); | 62 | 46.7k | OPENSSL_free(t); | 63 | 46.7k | } | 64 | 46.7k | } |
Unexecuted instantiation: tls13_enc.cc:void bssl::Delete<bssl::(anonymous namespace)::NullRecordNumberEncrypter>(bssl::(anonymous namespace)::NullRecordNumberEncrypter*) Unexecuted instantiation: tls13_enc.cc:void bssl::Delete<bssl::(anonymous namespace)::AES128RecordNumberEncrypter>(bssl::(anonymous namespace)::AES128RecordNumberEncrypter*) Unexecuted instantiation: tls13_enc.cc:void bssl::Delete<bssl::(anonymous namespace)::AES256RecordNumberEncrypter>(bssl::(anonymous namespace)::AES256RecordNumberEncrypter*) Unexecuted instantiation: tls13_enc.cc:void bssl::Delete<bssl::(anonymous namespace)::ChaChaRecordNumberEncrypter>(bssl::(anonymous namespace)::ChaChaRecordNumberEncrypter*) void bssl::Delete<bssl::MRUQueue<bssl::DTLSSentRecord, 32ul> >(bssl::MRUQueue<bssl::DTLSSentRecord, 32ul>*) Line | Count | Source | 59 | 10.6k | void Delete(T *t) { | 60 | 10.6k | if (t != nullptr) { | 61 | 10.6k | t->~T(); | 62 | 10.6k | OPENSSL_free(t); | 63 | 10.6k | } | 64 | 10.6k | } |
void bssl::Delete<bssl::DTLSIncomingMessage>(bssl::DTLSIncomingMessage*) Line | Count | Source | 59 | 55.1k | void Delete(T *t) { | 60 | 55.1k | if (t != nullptr) { | 61 | 55.1k | t->~T(); | 62 | 55.1k | OPENSSL_free(t); | 63 | 55.1k | } | 64 | 55.1k | } |
void bssl::Delete<bssl::DTLSWriteEpoch>(bssl::DTLSWriteEpoch*) Line | Count | Source | 59 | 8.26k | void Delete(T *t) { | 60 | 8.26k | if (t != nullptr) { | 61 | 8.26k | t->~T(); | 62 | 8.26k | OPENSSL_free(t); | 63 | 8.26k | } | 64 | 8.26k | } |
void bssl::Delete<bssl::DTLSReadEpoch>(bssl::DTLSReadEpoch*) Line | Count | Source | 59 | 39.1k | void Delete(T *t) { | 60 | 39.1k | if (t != nullptr) { | 61 | 39.1k | t->~T(); | 62 | 39.1k | OPENSSL_free(t); | 63 | 39.1k | } | 64 | 39.1k | } |
void bssl::Delete<bssl::DTLSPrevReadEpoch>(bssl::DTLSPrevReadEpoch*) Line | Count | Source | 59 | 36.6k | void Delete(T *t) { | 60 | 36.6k | if (t != nullptr) { | 61 | 36.6k | t->~T(); | 62 | 36.6k | OPENSSL_free(t); | 63 | 36.6k | } | 64 | 36.6k | } |
void bssl::Delete<bssl::DTLS1_STATE>(bssl::DTLS1_STATE*) Line | Count | Source | 59 | 41.1k | void Delete(T *t) { | 60 | 41.1k | if (t != nullptr) { | 61 | 41.1k | t->~T(); | 62 | 41.1k | OPENSSL_free(t); | 63 | 41.1k | } | 64 | 41.1k | } |
void bssl::Delete<bssl::SSL3_STATE>(bssl::SSL3_STATE*) Line | Count | Source | 59 | 121k | void Delete(T *t) { | 60 | 121k | if (t != nullptr) { | 61 | 121k | t->~T(); | 62 | 121k | OPENSSL_free(t); | 63 | 121k | } | 64 | 121k | } |
void bssl::Delete<bignum_ctx>(bignum_ctx*) Line | Count | Source | 59 | 131k | void Delete(T *t) { | 60 | 131k | if (t != nullptr) { | 61 | 118k | t->~T(); | 62 | 118k | OPENSSL_free(t); | 63 | 118k | } | 64 | 131k | } |
void bssl::Delete<evp_pkey_ctx_st>(evp_pkey_ctx_st*) Line | Count | Source | 59 | 175k | void Delete(T *t) { | 60 | 175k | if (t != nullptr) { | 61 | 175k | t->~T(); | 62 | 175k | OPENSSL_free(t); | 63 | 175k | } | 64 | 175k | } |
|
65 | | |
66 | | // All types with kAllowUniquePtr set may be used with UniquePtr. Other types |
67 | | // may be C structs which require a |BORINGSSL_MAKE_DELETER| registration. |
68 | | namespace internal { |
69 | | template <typename T> |
70 | | struct DeleterImpl<T, std::enable_if_t<T::kAllowUniquePtr>> { |
71 | 1.31M | static void Free(T *t) { Delete(t); } Unexecuted instantiation: bssl::internal::DeleterImpl<bssl::ECHConfig, void>::Free(bssl::ECHConfig*) bssl::internal::DeleterImpl<bssl::ECHServerConfig, void>::Free(bssl::ECHServerConfig*) Line | Count | Source | 71 | 11.8k | static void Free(T *t) { Delete(t); } |
bssl::internal::DeleterImpl<bssl::SSLPAKEShare, void>::Free(bssl::SSLPAKEShare*) Line | Count | Source | 71 | 11 | static void Free(T *t) { Delete(t); } |
bssl::internal::DeleterImpl<bssl::SSLKeyShare, void>::Free(bssl::SSLKeyShare*) Line | Count | Source | 71 | 183k | static void Free(T *t) { Delete(t); } |
Unexecuted instantiation: bssl::internal::DeleterImpl<bssl::spake2plus::Prover, void>::Free(bssl::spake2plus::Prover*) bssl::internal::DeleterImpl<bssl::SSLCipherPreferenceList, void>::Free(bssl::SSLCipherPreferenceList*) Line | Count | Source | 71 | 17.7k | static void Free(T *t) { Delete(t); } |
bssl::internal::DeleterImpl<bssl::SSL_HANDSHAKE, void>::Free(bssl::SSL_HANDSHAKE*) Line | Count | Source | 71 | 170k | static void Free(T *t) { Delete(t); } |
bssl::internal::DeleterImpl<bssl::SSL_HANDSHAKE_HINTS, void>::Free(bssl::SSL_HANDSHAKE_HINTS*) Line | Count | Source | 71 | 80.8k | static void Free(T *t) { Delete(t); } |
Unexecuted instantiation: bssl::internal::DeleterImpl<bssl::spake2plus::Verifier, void>::Free(bssl::spake2plus::Verifier*) bssl::internal::DeleterImpl<bssl::SSLAEADContext, void>::Free(bssl::SSLAEADContext*) Line | Count | Source | 71 | 402k | static void Free(T *t) { Delete(t); } |
bssl::internal::DeleterImpl<bssl::CERT, void>::Free(bssl::CERT*) Line | Count | Source | 71 | 126k | static void Free(T *t) { Delete(t); } |
Unexecuted instantiation: ssl_key_share.cc:bssl::internal::DeleterImpl<bssl::(anonymous namespace)::ECKeyShare, void>::Free(bssl::(anonymous namespace)::ECKeyShare*) Unexecuted instantiation: ssl_key_share.cc:bssl::internal::DeleterImpl<bssl::(anonymous namespace)::X25519KeyShare, void>::Free(bssl::(anonymous namespace)::X25519KeyShare*) Unexecuted instantiation: ssl_key_share.cc:bssl::internal::DeleterImpl<bssl::(anonymous namespace)::X25519Kyber768KeyShare, void>::Free(bssl::(anonymous namespace)::X25519Kyber768KeyShare*) Unexecuted instantiation: ssl_key_share.cc:bssl::internal::DeleterImpl<bssl::(anonymous namespace)::X25519MLKEM768KeyShare, void>::Free(bssl::(anonymous namespace)::X25519MLKEM768KeyShare*) bssl::internal::DeleterImpl<bssl::SSL_CONFIG, void>::Free(bssl::SSL_CONFIG*) Line | Count | Source | 71 | 121k | static void Free(T *t) { Delete(t); } |
bssl::internal::DeleterImpl<bssl::TicketKey, void>::Free(bssl::TicketKey*) Line | Count | Source | 71 | 389 | static void Free(T *t) { Delete(t); } |
bssl::internal::DeleterImpl<bssl::RecordNumberEncrypter, void>::Free(bssl::RecordNumberEncrypter*) Line | Count | Source | 71 | 46.7k | static void Free(T *t) { Delete(t); } |
Unexecuted instantiation: tls13_enc.cc:bssl::internal::DeleterImpl<bssl::(anonymous namespace)::NullRecordNumberEncrypter, void>::Free(bssl::(anonymous namespace)::NullRecordNumberEncrypter*) Unexecuted instantiation: tls13_enc.cc:bssl::internal::DeleterImpl<bssl::(anonymous namespace)::AES128RecordNumberEncrypter, void>::Free(bssl::(anonymous namespace)::AES128RecordNumberEncrypter*) Unexecuted instantiation: tls13_enc.cc:bssl::internal::DeleterImpl<bssl::(anonymous namespace)::AES256RecordNumberEncrypter, void>::Free(bssl::(anonymous namespace)::AES256RecordNumberEncrypter*) Unexecuted instantiation: tls13_enc.cc:bssl::internal::DeleterImpl<bssl::(anonymous namespace)::ChaChaRecordNumberEncrypter, void>::Free(bssl::(anonymous namespace)::ChaChaRecordNumberEncrypter*) bssl::internal::DeleterImpl<bssl::MRUQueue<bssl::DTLSSentRecord, 32ul>, void>::Free(bssl::MRUQueue<bssl::DTLSSentRecord, 32ul>*) Line | Count | Source | 71 | 10.6k | static void Free(T *t) { Delete(t); } |
bssl::internal::DeleterImpl<bssl::DTLSIncomingMessage, void>::Free(bssl::DTLSIncomingMessage*) Line | Count | Source | 71 | 55.1k | static void Free(T *t) { Delete(t); } |
bssl::internal::DeleterImpl<bssl::DTLSWriteEpoch, void>::Free(bssl::DTLSWriteEpoch*) Line | Count | Source | 71 | 8.26k | static void Free(T *t) { Delete(t); } |
bssl::internal::DeleterImpl<bssl::DTLSReadEpoch, void>::Free(bssl::DTLSReadEpoch*) Line | Count | Source | 71 | 39.1k | static void Free(T *t) { Delete(t); } |
bssl::internal::DeleterImpl<bssl::DTLSPrevReadEpoch, void>::Free(bssl::DTLSPrevReadEpoch*) Line | Count | Source | 71 | 36.6k | static void Free(T *t) { Delete(t); } |
Unexecuted instantiation: bssl::internal::DeleterImpl<bssl::DTLS1_STATE, void>::Free(bssl::DTLS1_STATE*) Unexecuted instantiation: bssl::internal::DeleterImpl<bssl::SSL3_STATE, void>::Free(bssl::SSL3_STATE*) |
72 | | }; |
73 | | } // namespace internal |
74 | | |
75 | | // MakeUnique behaves like |std::make_unique| but returns nullptr on allocation |
76 | | // error. |
77 | | template <typename T, typename... Args> |
78 | 2.29M | UniquePtr<T> MakeUnique(Args &&...args) { |
79 | 2.29M | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); |
80 | 2.29M | } Unexecuted instantiation: std::__1::unique_ptr<bssl::ECHConfig, bssl::internal::Deleter> bssl::MakeUnique<bssl::ECHConfig, bssl::ECHConfig>(bssl::ECHConfig&&) std::__1::unique_ptr<bssl::ECHServerConfig, bssl::internal::Deleter> bssl::MakeUnique<bssl::ECHServerConfig>() Line | Count | Source | 78 | 11.8k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 11.8k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 11.8k | } |
std::__1::unique_ptr<bssl::SSLPAKEShare, bssl::internal::Deleter> bssl::MakeUnique<bssl::SSLPAKEShare>() Line | Count | Source | 78 | 11 | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 11 | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 11 | } |
Unexecuted instantiation: std::__1::unique_ptr<bssl::spake2plus::Prover, bssl::internal::Deleter> bssl::MakeUnique<bssl::spake2plus::Prover>() std::__1::unique_ptr<bssl::SSLCipherPreferenceList, bssl::internal::Deleter> bssl::MakeUnique<bssl::SSLCipherPreferenceList>() Line | Count | Source | 78 | 17.7k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 17.7k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 17.7k | } |
std::__1::unique_ptr<bssl::SSL_HANDSHAKE_HINTS, bssl::internal::Deleter> bssl::MakeUnique<bssl::SSL_HANDSHAKE_HINTS>() Line | Count | Source | 78 | 80.8k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 80.8k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 80.8k | } |
std::__1::unique_ptr<bssl::SSL_HANDSHAKE, bssl::internal::Deleter> bssl::MakeUnique<bssl::SSL_HANDSHAKE, ssl_st*&>(ssl_st*&) Line | Count | Source | 78 | 170k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 170k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 170k | } |
std::__1::unique_ptr<bssl::SSLAEADContext, bssl::internal::Deleter> bssl::MakeUnique<bssl::SSLAEADContext, decltype(nullptr)>(decltype(nullptr)&&) Line | Count | Source | 78 | 243k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 243k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 243k | } |
std::__1::unique_ptr<bssl::SSLAEADContext, bssl::internal::Deleter> bssl::MakeUnique<bssl::SSLAEADContext, ssl_cipher_st const*&>(ssl_cipher_st const*&) Line | Count | Source | 78 | 159k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 159k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 159k | } |
std::__1::unique_ptr<ssl_credential_st, bssl::internal::Deleter> bssl::MakeUnique<ssl_credential_st, bssl::SSLCredentialType>(bssl::SSLCredentialType&&) Line | Count | Source | 78 | 126k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 126k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 126k | } |
std::__1::unique_ptr<bssl::CERT, bssl::internal::Deleter> bssl::MakeUnique<bssl::CERT, bssl::SSL_X509_METHOD const*&>(bssl::SSL_X509_METHOD const*&) Line | Count | Source | 78 | 121k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 121k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 121k | } |
Unexecuted instantiation: std::__1::unique_ptr<ssl_credential_st, bssl::internal::Deleter> bssl::MakeUnique<ssl_credential_st, bssl::SSLCredentialType&>(bssl::SSLCredentialType&) std::__1::unique_ptr<ssl_credential_st, bssl::internal::Deleter> bssl::MakeUnique<ssl_credential_st, bssl::SSLCredentialType const&>(bssl::SSLCredentialType const&) Line | Count | Source | 78 | 121k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 121k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 121k | } |
ssl_key_share.cc:std::__1::unique_ptr<bssl::(anonymous namespace)::ECKeyShare, bssl::internal::Deleter> bssl::MakeUnique<bssl::(anonymous namespace)::ECKeyShare, ec_group_st const*, int>(ec_group_st const*&&, int&&) Line | Count | Source | 78 | 32.0k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 32.0k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 32.0k | } |
ssl_key_share.cc:std::__1::unique_ptr<bssl::(anonymous namespace)::X25519KeyShare, bssl::internal::Deleter> bssl::MakeUnique<bssl::(anonymous namespace)::X25519KeyShare>() Line | Count | Source | 78 | 88.2k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 88.2k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 88.2k | } |
ssl_key_share.cc:std::__1::unique_ptr<bssl::(anonymous namespace)::X25519Kyber768KeyShare, bssl::internal::Deleter> bssl::MakeUnique<bssl::(anonymous namespace)::X25519Kyber768KeyShare>() Line | Count | Source | 78 | 215 | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 215 | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 215 | } |
ssl_key_share.cc:std::__1::unique_ptr<bssl::(anonymous namespace)::X25519MLKEM768KeyShare, bssl::internal::Deleter> bssl::MakeUnique<bssl::(anonymous namespace)::X25519MLKEM768KeyShare>() Line | Count | Source | 78 | 63.3k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 63.3k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 63.3k | } |
std::__1::unique_ptr<ssl_ctx_st, bssl::internal::Deleter> bssl::MakeUnique<ssl_ctx_st, ssl_method_st const*&>(ssl_method_st const*&) Line | Count | Source | 78 | 4.87k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 4.87k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 4.87k | } |
std::__1::unique_ptr<bssl::CERT, bssl::internal::Deleter> bssl::MakeUnique<bssl::CERT, bssl::SSL_X509_METHOD const* const&>(bssl::SSL_X509_METHOD const* const&) Line | Count | Source | 78 | 4.87k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 4.87k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 4.87k | } |
std::__1::unique_ptr<ssl_st, bssl::internal::Deleter> bssl::MakeUnique<ssl_st, ssl_ctx_st*&>(ssl_ctx_st*&) Line | Count | Source | 78 | 121k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 121k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 121k | } |
std::__1::unique_ptr<bssl::SSL_CONFIG, bssl::internal::Deleter> bssl::MakeUnique<bssl::SSL_CONFIG, ssl_st*>(ssl_st*&&) Line | Count | Source | 78 | 121k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 121k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 121k | } |
std::__1::unique_ptr<bssl::TicketKey, bssl::internal::Deleter> bssl::MakeUnique<bssl::TicketKey>() Line | Count | Source | 78 | 392 | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 392 | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 392 | } |
std::__1::unique_ptr<ssl_session_st, bssl::internal::Deleter> bssl::MakeUnique<ssl_session_st, bssl::SSL_X509_METHOD const*&>(bssl::SSL_X509_METHOD const*&) Line | Count | Source | 78 | 271k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 271k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 271k | } |
tls13_enc.cc:std::__1::unique_ptr<bssl::(anonymous namespace)::NullRecordNumberEncrypter, bssl::internal::Deleter> bssl::MakeUnique<bssl::(anonymous namespace)::NullRecordNumberEncrypter>() Line | Count | Source | 78 | 46.7k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 46.7k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 46.7k | } |
Unexecuted instantiation: tls13_enc.cc:std::__1::unique_ptr<bssl::(anonymous namespace)::AES128RecordNumberEncrypter, bssl::internal::Deleter> bssl::MakeUnique<bssl::(anonymous namespace)::AES128RecordNumberEncrypter>() Unexecuted instantiation: tls13_enc.cc:std::__1::unique_ptr<bssl::(anonymous namespace)::AES256RecordNumberEncrypter, bssl::internal::Deleter> bssl::MakeUnique<bssl::(anonymous namespace)::AES256RecordNumberEncrypter>() Unexecuted instantiation: tls13_enc.cc:std::__1::unique_ptr<bssl::(anonymous namespace)::ChaChaRecordNumberEncrypter, bssl::internal::Deleter> bssl::MakeUnique<bssl::(anonymous namespace)::ChaChaRecordNumberEncrypter>() Unexecuted instantiation: std::__1::unique_ptr<bssl::spake2plus::Verifier, bssl::internal::Deleter> bssl::MakeUnique<bssl::spake2plus::Verifier>() std::__1::unique_ptr<bssl::DTLSIncomingMessage, bssl::internal::Deleter> bssl::MakeUnique<bssl::DTLSIncomingMessage>() Line | Count | Source | 78 | 55.1k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 55.1k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 55.1k | } |
std::__1::unique_ptr<bssl::MRUQueue<bssl::DTLSSentRecord, 32ul>, bssl::internal::Deleter> bssl::MakeUnique<bssl::MRUQueue<bssl::DTLSSentRecord, 32ul>>() Line | Count | Source | 78 | 10.6k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 10.6k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 10.6k | } |
std::__1::unique_ptr<bssl::DTLS1_STATE, bssl::internal::Deleter> bssl::MakeUnique<bssl::DTLS1_STATE>() Line | Count | Source | 78 | 41.1k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 41.1k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 41.1k | } |
std::__1::unique_ptr<bssl::DTLSPrevReadEpoch, bssl::internal::Deleter> bssl::MakeUnique<bssl::DTLSPrevReadEpoch>() Line | Count | Source | 78 | 36.6k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 36.6k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 36.6k | } |
std::__1::unique_ptr<bssl::SSL3_STATE, bssl::internal::Deleter> bssl::MakeUnique<bssl::SSL3_STATE>() Line | Count | Source | 78 | 121k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 121k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 121k | } |
std::__1::unique_ptr<evp_pkey_ctx_st, bssl::internal::Deleter> bssl::MakeUnique<evp_pkey_ctx_st>() Line | Count | Source | 78 | 175k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 175k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 175k | } |
std::__1::unique_ptr<bssl::DTLSReadEpoch, bssl::internal::Deleter> bssl::MakeUnique<bssl::DTLSReadEpoch, bssl::DTLSReadEpoch>(bssl::DTLSReadEpoch&&) Line | Count | Source | 78 | 39.1k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 39.1k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 39.1k | } |
std::__1::unique_ptr<bssl::DTLSWriteEpoch, bssl::internal::Deleter> bssl::MakeUnique<bssl::DTLSWriteEpoch, bssl::DTLSWriteEpoch>(bssl::DTLSWriteEpoch&&) Line | Count | Source | 78 | 8.26k | UniquePtr<T> MakeUnique(Args &&...args) { | 79 | 8.26k | return UniquePtr<T>(New<T>(std::forward<Args>(args)...)); | 80 | 8.26k | } |
|
81 | | |
82 | | |
83 | | // Containers. |
84 | | |
85 | | // Array<T> is an owning array of elements of |T|. |
86 | | template <typename T> |
87 | | class Array { |
88 | | public: |
89 | | // Array's default constructor creates an empty array. |
90 | 9.35M | Array() {} bssl::Array<unsigned char>::Array() Line | Count | Source | 90 | 8.06M | Array() {} |
bssl::Array<unsigned short>::Array() Line | Count | Source | 90 | 1.20M | Array() {} |
bssl::Array<ssl_credential_st*>::Array() Line | Count | Source | 90 | 38.2k | Array() {} |
bssl::Array<int>::Array() Line | Count | Source | 90 | 8.51k | Array() {} |
bssl::Array<bool>::Array() Line | Count | Source | 90 | 35.4k | Array() {} |
|
91 | | Array(const Array &) = delete; |
92 | 424k | Array(Array &&other) { *this = std::move(other); } |
93 | | |
94 | 9.77M | ~Array() { Reset(); } bssl::Array<unsigned char>::~Array() Line | Count | Source | 94 | 8.49M | ~Array() { Reset(); } |
bssl::Array<unsigned short>::~Array() Line | Count | Source | 94 | 1.20M | ~Array() { Reset(); } |
bssl::Array<ssl_credential_st*>::~Array() Line | Count | Source | 94 | 38.2k | ~Array() { Reset(); } |
bssl::Array<int>::~Array() Line | Count | Source | 94 | 8.51k | ~Array() { Reset(); } |
bssl::Array<bool>::~Array() Line | Count | Source | 94 | 35.4k | ~Array() { Reset(); } |
|
95 | | |
96 | | Array &operator=(const Array &) = delete; |
97 | 562k | Array &operator=(Array &&other) { |
98 | 562k | Reset(); |
99 | 562k | other.Release(&data_, &size_); |
100 | 562k | return *this; |
101 | 562k | } bssl::Array<unsigned char>::operator=(bssl::Array<unsigned char>&&) Line | Count | Source | 97 | 512k | Array &operator=(Array &&other) { | 98 | 512k | Reset(); | 99 | 512k | other.Release(&data_, &size_); | 100 | 512k | return *this; | 101 | 512k | } |
bssl::Array<unsigned short>::operator=(bssl::Array<unsigned short>&&) Line | Count | Source | 97 | 50.5k | Array &operator=(Array &&other) { | 98 | 50.5k | Reset(); | 99 | 50.5k | other.Release(&data_, &size_); | 100 | 50.5k | return *this; | 101 | 50.5k | } |
|
102 | | |
103 | 2.41M | const T *data() const { return data_; } bssl::Array<unsigned char>::data() const Line | Count | Source | 103 | 1.77M | const T *data() const { return data_; } |
bssl::Array<unsigned short>::data() const Line | Count | Source | 103 | 622k | const T *data() const { return data_; } |
bssl::Array<bool>::data() const Line | Count | Source | 103 | 17.7k | const T *data() const { return data_; } |
|
104 | 372k | T *data() { return data_; } bssl::Array<unsigned char>::data() Line | Count | Source | 104 | 369k | T *data() { return data_; } |
bssl::Array<unsigned short>::data() Line | Count | Source | 104 | 3.34k | T *data() { return data_; } |
|
105 | 7.52M | size_t size() const { return size_; } bssl::Array<unsigned char>::size() const Line | Count | Source | 105 | 5.69M | size_t size() const { return size_; } |
bssl::Array<unsigned short>::size() const Line | Count | Source | 105 | 1.81M | size_t size() const { return size_; } |
bssl::Array<bool>::size() const Line | Count | Source | 105 | 17.7k | size_t size() const { return size_; } |
|
106 | 3.43M | bool empty() const { return size_ == 0; } bssl::Array<unsigned char>::empty() const Line | Count | Source | 106 | 3.03M | bool empty() const { return size_ == 0; } |
bssl::Array<unsigned short>::empty() const Line | Count | Source | 106 | 365k | bool empty() const { return size_ == 0; } |
bssl::Array<ssl_credential_st*>::empty() const Line | Count | Source | 106 | 38.2k | bool empty() const { return size_ == 0; } |
|
107 | | |
108 | 2.02M | const T &operator[](size_t i) const { |
109 | 2.02M | BSSL_CHECK(i < size_); |
110 | 2.02M | return data_[i]; |
111 | 2.02M | } |
112 | 5.75M | T &operator[](size_t i) { |
113 | 5.75M | BSSL_CHECK(i < size_); |
114 | 5.75M | return data_[i]; |
115 | 5.75M | } bssl::Array<unsigned short>::operator[](unsigned long) Line | Count | Source | 112 | 2.22M | T &operator[](size_t i) { | 113 | 2.22M | BSSL_CHECK(i < size_); | 114 | 2.22M | return data_[i]; | 115 | 2.22M | } |
bssl::Array<unsigned char>::operator[](unsigned long) Line | Count | Source | 112 | 1.80M | T &operator[](size_t i) { | 113 | 1.80M | BSSL_CHECK(i < size_); | 114 | 1.80M | return data_[i]; | 115 | 1.80M | } |
bssl::Array<int>::operator[](unsigned long) Line | Count | Source | 112 | 1.53M | T &operator[](size_t i) { | 113 | 1.53M | BSSL_CHECK(i < size_); | 114 | 1.53M | return data_[i]; | 115 | 1.53M | } |
bssl::Array<bool>::operator[](unsigned long) Line | Count | Source | 112 | 160k | T &operator[](size_t i) { | 113 | 160k | BSSL_CHECK(i < size_); | 114 | 160k | return data_[i]; | 115 | 160k | } |
bssl::Array<ssl_credential_st*>::operator[](unsigned long) Line | Count | Source | 112 | 38.2k | T &operator[](size_t i) { | 113 | 38.2k | BSSL_CHECK(i < size_); | 114 | 38.2k | return data_[i]; | 115 | 38.2k | } |
|
116 | | |
117 | | T &front() { |
118 | | BSSL_CHECK(size_ != 0); |
119 | | return data_[0]; |
120 | | } |
121 | | const T &front() const { |
122 | | BSSL_CHECK(size_ != 0); |
123 | | return data_[0]; |
124 | | } |
125 | | T &back() { |
126 | | BSSL_CHECK(size_ != 0); |
127 | | return data_[size_ - 1]; |
128 | | } |
129 | | const T &back() const { |
130 | | BSSL_CHECK(size_ != 0); |
131 | | return data_[size_ - 1]; |
132 | | } |
133 | | |
134 | 180k | T *begin() { return data_; } bssl::Array<unsigned short>::begin() Line | Count | Source | 134 | 116k | T *begin() { return data_; } |
bssl::Array<ssl_credential_st*>::begin() Line | Count | Source | 134 | 38.2k | T *begin() { return data_; } |
bssl::Array<unsigned char>::begin() Line | Count | Source | 134 | 25.7k | T *begin() { return data_; } |
|
135 | | const T *begin() const { return data_; } |
136 | 205k | T *end() { return data_ + size_; } bssl::Array<unsigned short>::end() Line | Count | Source | 136 | 116k | T *end() { return data_ + size_; } |
bssl::Array<ssl_credential_st*>::end() Line | Count | Source | 136 | 38.2k | T *end() { return data_ + size_; } |
bssl::Array<unsigned char>::end() Line | Count | Source | 136 | 51.5k | T *end() { return data_ + size_; } |
|
137 | | const T *end() const { return data_ + size_; } |
138 | | |
139 | 12.9M | void Reset() { Reset(nullptr, 0); } bssl::Array<unsigned char>::Reset() Line | Count | Source | 139 | 11.0M | void Reset() { Reset(nullptr, 0); } |
bssl::Array<unsigned short>::Reset() Line | Count | Source | 139 | 1.82M | void Reset() { Reset(nullptr, 0); } |
bssl::Array<ssl_credential_st*>::Reset() Line | Count | Source | 139 | 76.4k | void Reset() { Reset(nullptr, 0); } |
bssl::Array<int>::Reset() Line | Count | Source | 139 | 17.0k | void Reset() { Reset(nullptr, 0); } |
bssl::Array<bool>::Reset() Line | Count | Source | 139 | 70.9k | void Reset() { Reset(nullptr, 0); } |
|
140 | | |
141 | | // Reset releases the current contents of the array and takes ownership of the |
142 | | // raw pointer supplied by the caller. |
143 | 13.3M | void Reset(T *new_data, size_t new_size) { |
144 | 13.3M | std::destroy_n(data_, size_); |
145 | 13.3M | OPENSSL_free(data_); |
146 | 13.3M | data_ = new_data; |
147 | 13.3M | size_ = new_size; |
148 | 13.3M | } bssl::Array<unsigned char>::Reset(unsigned char*, unsigned long) Line | Count | Source | 143 | 11.4M | void Reset(T *new_data, size_t new_size) { | 144 | 11.4M | std::destroy_n(data_, size_); | 145 | 11.4M | OPENSSL_free(data_); | 146 | 11.4M | data_ = new_data; | 147 | 11.4M | size_ = new_size; | 148 | 11.4M | } |
bssl::Array<unsigned short>::Reset(unsigned short*, unsigned long) Line | Count | Source | 143 | 1.82M | void Reset(T *new_data, size_t new_size) { | 144 | 1.82M | std::destroy_n(data_, size_); | 145 | 1.82M | OPENSSL_free(data_); | 146 | 1.82M | data_ = new_data; | 147 | 1.82M | size_ = new_size; | 148 | 1.82M | } |
bssl::Array<ssl_credential_st*>::Reset(ssl_credential_st**, unsigned long) Line | Count | Source | 143 | 76.4k | void Reset(T *new_data, size_t new_size) { | 144 | 76.4k | std::destroy_n(data_, size_); | 145 | 76.4k | OPENSSL_free(data_); | 146 | 76.4k | data_ = new_data; | 147 | 76.4k | size_ = new_size; | 148 | 76.4k | } |
bssl::Array<int>::Reset(int*, unsigned long) Line | Count | Source | 143 | 17.0k | void Reset(T *new_data, size_t new_size) { | 144 | 17.0k | std::destroy_n(data_, size_); | 145 | 17.0k | OPENSSL_free(data_); | 146 | 17.0k | data_ = new_data; | 147 | 17.0k | size_ = new_size; | 148 | 17.0k | } |
bssl::Array<bool>::Reset(bool*, unsigned long) Line | Count | Source | 143 | 70.9k | void Reset(T *new_data, size_t new_size) { | 144 | 70.9k | std::destroy_n(data_, size_); | 145 | 70.9k | OPENSSL_free(data_); | 146 | 70.9k | data_ = new_data; | 147 | 70.9k | size_ = new_size; | 148 | 70.9k | } |
|
149 | | |
150 | | // Release releases ownership of the array to a raw pointer supplied by the |
151 | | // caller. |
152 | 580k | void Release(T **out, size_t *out_size) { |
153 | 580k | *out = data_; |
154 | 580k | *out_size = size_; |
155 | 580k | data_ = nullptr; |
156 | 580k | size_ = 0; |
157 | 580k | } bssl::Array<unsigned char>::Release(unsigned char**, unsigned long*) Line | Count | Source | 152 | 512k | void Release(T **out, size_t *out_size) { | 153 | 512k | *out = data_; | 154 | 512k | *out_size = size_; | 155 | 512k | data_ = nullptr; | 156 | 512k | size_ = 0; | 157 | 512k | } |
bssl::Array<unsigned short>::Release(unsigned short**, unsigned long*) Line | Count | Source | 152 | 50.5k | void Release(T **out, size_t *out_size) { | 153 | 50.5k | *out = data_; | 154 | 50.5k | *out_size = size_; | 155 | 50.5k | data_ = nullptr; | 156 | 50.5k | size_ = 0; | 157 | 50.5k | } |
bssl::Array<bool>::Release(bool**, unsigned long*) Line | Count | Source | 152 | 17.7k | void Release(T **out, size_t *out_size) { | 153 | 17.7k | *out = data_; | 154 | 17.7k | *out_size = size_; | 155 | 17.7k | data_ = nullptr; | 156 | 17.7k | size_ = 0; | 157 | 17.7k | } |
|
158 | | |
159 | | // Init replaces the array with a newly-allocated array of |new_size| |
160 | | // value-constructed copies of |T|. It returns true on success and false on |
161 | | // error. If |T| is a primitive type like |uint8_t|, value-construction means |
162 | | // it will be zero-initialized. |
163 | 93.6k | [[nodiscard]] bool Init(size_t new_size) { |
164 | 93.6k | if (!InitUninitialized(new_size)) { |
165 | 0 | return false; |
166 | 0 | } |
167 | 93.6k | std::uninitialized_value_construct_n(data_, size_); |
168 | 93.6k | return true; |
169 | 93.6k | } bssl::Array<unsigned char>::Init(unsigned long) Line | Count | Source | 163 | 85.1k | [[nodiscard]] bool Init(size_t new_size) { | 164 | 85.1k | if (!InitUninitialized(new_size)) { | 165 | 0 | return false; | 166 | 0 | } | 167 | 85.1k | std::uninitialized_value_construct_n(data_, size_); | 168 | 85.1k | return true; | 169 | 85.1k | } |
bssl::Array<int>::Init(unsigned long) Line | Count | Source | 163 | 8.51k | [[nodiscard]] bool Init(size_t new_size) { | 164 | 8.51k | if (!InitUninitialized(new_size)) { | 165 | 0 | return false; | 166 | 0 | } | 167 | 8.51k | std::uninitialized_value_construct_n(data_, size_); | 168 | 8.51k | return true; | 169 | 8.51k | } |
|
170 | | |
171 | | // InitForOverwrite behaves like |Init| but it default-constructs each element |
172 | | // instead. This means that, if |T| is a primitive type, the array will be |
173 | | // uninitialized and thus must be filled in by the caller. |
174 | 420k | [[nodiscard]] bool InitForOverwrite(size_t new_size) { |
175 | 420k | if (!InitUninitialized(new_size)) { |
176 | 0 | return false; |
177 | 0 | } |
178 | 420k | std::uninitialized_default_construct_n(data_, size_); |
179 | 420k | return true; |
180 | 420k | } bssl::Array<unsigned char>::InitForOverwrite(unsigned long) Line | Count | Source | 174 | 179k | [[nodiscard]] bool InitForOverwrite(size_t new_size) { | 175 | 179k | if (!InitUninitialized(new_size)) { | 176 | 0 | return false; | 177 | 0 | } | 178 | 179k | std::uninitialized_default_construct_n(data_, size_); | 179 | 179k | return true; | 180 | 179k | } |
bssl::Array<unsigned short>::InitForOverwrite(unsigned long) Line | Count | Source | 174 | 185k | [[nodiscard]] bool InitForOverwrite(size_t new_size) { | 175 | 185k | if (!InitUninitialized(new_size)) { | 176 | 0 | return false; | 177 | 0 | } | 178 | 185k | std::uninitialized_default_construct_n(data_, size_); | 179 | 185k | return true; | 180 | 185k | } |
bssl::Array<bool>::InitForOverwrite(unsigned long) Line | Count | Source | 174 | 17.7k | [[nodiscard]] bool InitForOverwrite(size_t new_size) { | 175 | 17.7k | if (!InitUninitialized(new_size)) { | 176 | 0 | return false; | 177 | 0 | } | 178 | 17.7k | std::uninitialized_default_construct_n(data_, size_); | 179 | 17.7k | return true; | 180 | 17.7k | } |
bssl::Array<ssl_credential_st*>::InitForOverwrite(unsigned long) Line | Count | Source | 174 | 38.2k | [[nodiscard]] bool InitForOverwrite(size_t new_size) { | 175 | 38.2k | if (!InitUninitialized(new_size)) { | 176 | 0 | return false; | 177 | 0 | } | 178 | 38.2k | std::uninitialized_default_construct_n(data_, size_); | 179 | 38.2k | return true; | 180 | 38.2k | } |
|
181 | | |
182 | | // CopyFrom replaces the array with a newly-allocated copy of |in|. It returns |
183 | | // true on success and false on error. |
184 | 1.65M | [[nodiscard]] bool CopyFrom(Span<const T> in) { |
185 | 1.65M | if (!InitUninitialized(in.size())) { |
186 | 0 | return false; |
187 | 0 | } |
188 | 1.65M | std::uninitialized_copy(in.begin(), in.end(), data_); |
189 | 1.65M | return true; |
190 | 1.65M | } bssl::Array<unsigned char>::CopyFrom(bssl::Span<unsigned char const>) Line | Count | Source | 184 | 1.26M | [[nodiscard]] bool CopyFrom(Span<const T> in) { | 185 | 1.26M | if (!InitUninitialized(in.size())) { | 186 | 0 | return false; | 187 | 0 | } | 188 | 1.26M | std::uninitialized_copy(in.begin(), in.end(), data_); | 189 | 1.26M | return true; | 190 | 1.26M | } |
bssl::Array<bool>::CopyFrom(bssl::Span<bool const>) Line | Count | Source | 184 | 17.7k | [[nodiscard]] bool CopyFrom(Span<const T> in) { | 185 | 17.7k | if (!InitUninitialized(in.size())) { | 186 | 0 | return false; | 187 | 0 | } | 188 | 17.7k | std::uninitialized_copy(in.begin(), in.end(), data_); | 189 | 17.7k | return true; | 190 | 17.7k | } |
bssl::Array<unsigned short>::CopyFrom(bssl::Span<unsigned short const>) Line | Count | Source | 184 | 371k | [[nodiscard]] bool CopyFrom(Span<const T> in) { | 185 | 371k | if (!InitUninitialized(in.size())) { | 186 | 0 | return false; | 187 | 0 | } | 188 | 371k | std::uninitialized_copy(in.begin(), in.end(), data_); | 189 | 371k | return true; | 190 | 371k | } |
|
191 | | |
192 | | // Shrink shrinks the stored size of the array to |new_size|. It crashes if |
193 | | // the new size is larger. Note this does not shrink the allocation itself. |
194 | 20.8k | void Shrink(size_t new_size) { |
195 | 20.8k | if (new_size > size_) { |
196 | 0 | abort(); |
197 | 0 | } |
198 | 20.8k | std::destroy_n(data_ + new_size, size_ - new_size); |
199 | 20.8k | size_ = new_size; |
200 | 20.8k | } Unexecuted instantiation: bssl::Array<unsigned char>::Shrink(unsigned long) bssl::Array<unsigned short>::Shrink(unsigned long) Line | Count | Source | 194 | 3.15k | void Shrink(size_t new_size) { | 195 | 3.15k | if (new_size > size_) { | 196 | 0 | abort(); | 197 | 0 | } | 198 | 3.15k | std::destroy_n(data_ + new_size, size_ - new_size); | 199 | 3.15k | size_ = new_size; | 200 | 3.15k | } |
bssl::Array<bool>::Shrink(unsigned long) Line | Count | Source | 194 | 17.7k | void Shrink(size_t new_size) { | 195 | 17.7k | if (new_size > size_) { | 196 | 0 | abort(); | 197 | 0 | } | 198 | 17.7k | std::destroy_n(data_ + new_size, size_ - new_size); | 199 | 17.7k | size_ = new_size; | 200 | 17.7k | } |
|
201 | | |
202 | | private: |
203 | | // InitUninitialized replaces the array with a newly-allocated array of |
204 | | // |new_size| elements, but whose constructor has not yet run. On success, the |
205 | | // elements must be constructed before returning control to the caller. |
206 | 2.16M | bool InitUninitialized(size_t new_size) { |
207 | 2.16M | Reset(); |
208 | 2.16M | if (new_size == 0) { |
209 | 1.11M | return true; |
210 | 1.11M | } |
211 | | |
212 | 1.05M | if (new_size > SIZE_MAX / sizeof(T)) { |
213 | 0 | OPENSSL_PUT_ERROR(CRYPTO, ERR_R_OVERFLOW); |
214 | 0 | return false; |
215 | 0 | } |
216 | 1.05M | data_ = reinterpret_cast<T *>(OPENSSL_malloc(new_size * sizeof(T))); |
217 | 1.05M | if (data_ == nullptr) { |
218 | 0 | return false; |
219 | 0 | } |
220 | 1.05M | size_ = new_size; |
221 | 1.05M | return true; |
222 | 1.05M | } bssl::Array<unsigned char>::InitUninitialized(unsigned long) Line | Count | Source | 206 | 1.53M | bool InitUninitialized(size_t new_size) { | 207 | 1.53M | Reset(); | 208 | 1.53M | if (new_size == 0) { | 209 | 851k | return true; | 210 | 851k | } | 211 | | | 212 | 679k | if (new_size > SIZE_MAX / sizeof(T)) { | 213 | 0 | OPENSSL_PUT_ERROR(CRYPTO, ERR_R_OVERFLOW); | 214 | 0 | return false; | 215 | 0 | } | 216 | 679k | data_ = reinterpret_cast<T *>(OPENSSL_malloc(new_size * sizeof(T))); | 217 | 679k | if (data_ == nullptr) { | 218 | 0 | return false; | 219 | 0 | } | 220 | 679k | size_ = new_size; | 221 | 679k | return true; | 222 | 679k | } |
bssl::Array<unsigned short>::InitUninitialized(unsigned long) Line | Count | Source | 206 | 556k | bool InitUninitialized(size_t new_size) { | 207 | 556k | Reset(); | 208 | 556k | if (new_size == 0) { | 209 | 255k | return true; | 210 | 255k | } | 211 | | | 212 | 301k | if (new_size > SIZE_MAX / sizeof(T)) { | 213 | 0 | OPENSSL_PUT_ERROR(CRYPTO, ERR_R_OVERFLOW); | 214 | 0 | return false; | 215 | 0 | } | 216 | 301k | data_ = reinterpret_cast<T *>(OPENSSL_malloc(new_size * sizeof(T))); | 217 | 301k | if (data_ == nullptr) { | 218 | 0 | return false; | 219 | 0 | } | 220 | 301k | size_ = new_size; | 221 | 301k | return true; | 222 | 301k | } |
bssl::Array<int>::InitUninitialized(unsigned long) Line | Count | Source | 206 | 8.51k | bool InitUninitialized(size_t new_size) { | 207 | 8.51k | Reset(); | 208 | 8.51k | if (new_size == 0) { | 209 | 0 | return true; | 210 | 0 | } | 211 | | | 212 | 8.51k | if (new_size > SIZE_MAX / sizeof(T)) { | 213 | 0 | OPENSSL_PUT_ERROR(CRYPTO, ERR_R_OVERFLOW); | 214 | 0 | return false; | 215 | 0 | } | 216 | 8.51k | data_ = reinterpret_cast<T *>(OPENSSL_malloc(new_size * sizeof(T))); | 217 | 8.51k | if (data_ == nullptr) { | 218 | 0 | return false; | 219 | 0 | } | 220 | 8.51k | size_ = new_size; | 221 | 8.51k | return true; | 222 | 8.51k | } |
bssl::Array<bool>::InitUninitialized(unsigned long) Line | Count | Source | 206 | 35.4k | bool InitUninitialized(size_t new_size) { | 207 | 35.4k | Reset(); | 208 | 35.4k | if (new_size == 0) { | 209 | 7.63k | return true; | 210 | 7.63k | } | 211 | | | 212 | 27.8k | if (new_size > SIZE_MAX / sizeof(T)) { | 213 | 0 | OPENSSL_PUT_ERROR(CRYPTO, ERR_R_OVERFLOW); | 214 | 0 | return false; | 215 | 0 | } | 216 | 27.8k | data_ = reinterpret_cast<T *>(OPENSSL_malloc(new_size * sizeof(T))); | 217 | 27.8k | if (data_ == nullptr) { | 218 | 0 | return false; | 219 | 0 | } | 220 | 27.8k | size_ = new_size; | 221 | 27.8k | return true; | 222 | 27.8k | } |
bssl::Array<ssl_credential_st*>::InitUninitialized(unsigned long) Line | Count | Source | 206 | 38.2k | bool InitUninitialized(size_t new_size) { | 207 | 38.2k | Reset(); | 208 | 38.2k | if (new_size == 0) { | 209 | 0 | return true; | 210 | 0 | } | 211 | | | 212 | 38.2k | if (new_size > SIZE_MAX / sizeof(T)) { | 213 | 0 | OPENSSL_PUT_ERROR(CRYPTO, ERR_R_OVERFLOW); | 214 | 0 | return false; | 215 | 0 | } | 216 | 38.2k | data_ = reinterpret_cast<T *>(OPENSSL_malloc(new_size * sizeof(T))); | 217 | 38.2k | if (data_ == nullptr) { | 218 | 0 | return false; | 219 | 0 | } | 220 | 38.2k | size_ = new_size; | 221 | 38.2k | return true; | 222 | 38.2k | } |
|
223 | | |
224 | | T *data_ = nullptr; |
225 | | size_t size_ = 0; |
226 | | }; |
227 | | |
228 | | // Vector<T> is a resizable array of elements of |T|. |
229 | | template <typename T> |
230 | | class Vector { |
231 | | public: |
232 | 503k | Vector() = default; bssl::Vector<std::__1::unique_ptr<bssl::ECHServerConfig, bssl::internal::Deleter> >::Vector() Line | Count | Source | 232 | 13.6k | Vector() = default; |
bssl::Vector<std::__1::unique_ptr<ssl_credential_st, bssl::internal::Deleter> >::Vector() Line | Count | Source | 232 | 126k | Vector() = default; |
bssl::Vector<bssl::CertCompressionAlg>::Vector() Line | Count | Source | 232 | 4.87k | Vector() = default; |
bssl::Vector<bssl::ALPSConfig>::Vector() Line | Count | Source | 232 | 121k | Vector() = default; |
bssl::Vector<std::__1::unique_ptr<bignum_st, bssl::internal::Deleter> >::Vector() Line | Count | Source | 232 | 118k | Vector() = default; |
bssl::Vector<unsigned long>::Vector() Line | Count | Source | 232 | 118k | Vector() = default; |
|
233 | | Vector(const Vector &) = delete; |
234 | | Vector(Vector &&other) { *this = std::move(other); } |
235 | 503k | ~Vector() { clear(); } bssl::Vector<std::__1::unique_ptr<bssl::ECHServerConfig, bssl::internal::Deleter> >::~Vector() Line | Count | Source | 235 | 13.6k | ~Vector() { clear(); } |
bssl::Vector<std::__1::unique_ptr<ssl_credential_st, bssl::internal::Deleter> >::~Vector() Line | Count | Source | 235 | 126k | ~Vector() { clear(); } |
bssl::Vector<bssl::CertCompressionAlg>::~Vector() Line | Count | Source | 235 | 4.86k | ~Vector() { clear(); } |
bssl::Vector<bssl::ALPSConfig>::~Vector() Line | Count | Source | 235 | 121k | ~Vector() { clear(); } |
bssl::Vector<unsigned long>::~Vector() Line | Count | Source | 235 | 118k | ~Vector() { clear(); } |
bssl::Vector<std::__1::unique_ptr<bignum_st, bssl::internal::Deleter> >::~Vector() Line | Count | Source | 235 | 118k | ~Vector() { clear(); } |
|
236 | | |
237 | | Vector &operator=(const Vector &) = delete; |
238 | | Vector &operator=(Vector &&other) { |
239 | | clear(); |
240 | | std::swap(data_, other.data_); |
241 | | std::swap(size_, other.size_); |
242 | | std::swap(capacity_, other.capacity_); |
243 | | return *this; |
244 | | } |
245 | | |
246 | | const T *data() const { return data_; } |
247 | | T *data() { return data_; } |
248 | 34.9M | size_t size() const { return size_; } bssl::Vector<bssl::CertCompressionAlg>::size() const Line | Count | Source | 248 | 73 | size_t size() const { return size_; } |
bssl::Vector<std::__1::unique_ptr<ssl_credential_st, bssl::internal::Deleter> >::size() const Line | Count | Source | 248 | 76.4k | size_t size() const { return size_; } |
bssl::Vector<std::__1::unique_ptr<bignum_st, bssl::internal::Deleter> >::size() const Line | Count | Source | 248 | 34.8M | size_t size() const { return size_; } |
|
249 | 20.9M | bool empty() const { return size_ == 0; } bssl::Vector<bssl::ALPSConfig>::empty() const Line | Count | Source | 249 | 129k | bool empty() const { return size_ == 0; } |
bssl::Vector<std::__1::unique_ptr<ssl_credential_st, bssl::internal::Deleter> >::empty() const Line | Count | Source | 249 | 6 | bool empty() const { return size_ == 0; } |
bssl::Vector<unsigned long>::empty() const Line | Count | Source | 249 | 20.8M | bool empty() const { return size_ == 0; } |
|
250 | | |
251 | 0 | const T &operator[](size_t i) const { |
252 | 0 | BSSL_CHECK(i < size_); |
253 | 0 | return data_[i]; |
254 | 0 | } Unexecuted instantiation: bssl::Vector<bssl::CertCompressionAlg>::operator[](unsigned long) const Unexecuted instantiation: bssl::Vector<std::__1::unique_ptr<ssl_credential_st, bssl::internal::Deleter> >::operator[](unsigned long) const |
255 | 34.8M | T &operator[](size_t i) { |
256 | 34.8M | BSSL_CHECK(i < size_); |
257 | 34.8M | return data_[i]; |
258 | 34.8M | } Unexecuted instantiation: bssl::Vector<std::__1::unique_ptr<ssl_credential_st, bssl::internal::Deleter> >::operator[](unsigned long) bssl::Vector<std::__1::unique_ptr<bignum_st, bssl::internal::Deleter> >::operator[](unsigned long) Line | Count | Source | 255 | 34.8M | T &operator[](size_t i) { | 256 | 34.8M | BSSL_CHECK(i < size_); | 257 | 34.8M | return data_[i]; | 258 | 34.8M | } |
|
259 | | |
260 | | T &front() { |
261 | | BSSL_CHECK(size_ != 0); |
262 | | return data_[0]; |
263 | | } |
264 | | const T &front() const { |
265 | | BSSL_CHECK(size_ != 0); |
266 | | return data_[0]; |
267 | | } |
268 | 20.8M | T &back() { |
269 | 20.8M | BSSL_CHECK(size_ != 0); |
270 | 20.8M | return data_[size_ - 1]; |
271 | 20.8M | } |
272 | | const T &back() const { |
273 | | BSSL_CHECK(size_ != 0); |
274 | | return data_[size_ - 1]; |
275 | | } |
276 | | |
277 | 305k | T *begin() { return data_; } bssl::Vector<std::__1::unique_ptr<bssl::ECHServerConfig, bssl::internal::Deleter> >::begin() Line | Count | Source | 277 | 496 | T *begin() { return data_; } |
bssl::Vector<bssl::CertCompressionAlg>::begin() Line | Count | Source | 277 | 64.8k | T *begin() { return data_; } |
bssl::Vector<std::__1::unique_ptr<ssl_credential_st, bssl::internal::Deleter> >::begin() Line | Count | Source | 277 | 121k | T *begin() { return data_; } |
bssl::Vector<bssl::ALPSConfig>::begin() Line | Count | Source | 277 | 25 | T *begin() { return data_; } |
bssl::Vector<unsigned long>::begin() Line | Count | Source | 277 | 56.8k | T *begin() { return data_; } |
bssl::Vector<std::__1::unique_ptr<bignum_st, bssl::internal::Deleter> >::begin() Line | Count | Source | 277 | 61.1k | T *begin() { return data_; } |
|
278 | 63.0k | const T *begin() const { return data_; } Unexecuted instantiation: bssl::Vector<std::__1::unique_ptr<bssl::ECHServerConfig, bssl::internal::Deleter> >::begin() const bssl::Vector<std::__1::unique_ptr<ssl_credential_st, bssl::internal::Deleter> >::begin() const Line | Count | Source | 278 | 63.0k | const T *begin() const { return data_; } |
|
279 | 305k | T *end() { return data_ + size_; } bssl::Vector<std::__1::unique_ptr<bssl::ECHServerConfig, bssl::internal::Deleter> >::end() Line | Count | Source | 279 | 496 | T *end() { return data_ + size_; } |
bssl::Vector<bssl::CertCompressionAlg>::end() Line | Count | Source | 279 | 64.8k | T *end() { return data_ + size_; } |
bssl::Vector<std::__1::unique_ptr<ssl_credential_st, bssl::internal::Deleter> >::end() Line | Count | Source | 279 | 121k | T *end() { return data_ + size_; } |
bssl::Vector<bssl::ALPSConfig>::end() Line | Count | Source | 279 | 25 | T *end() { return data_ + size_; } |
bssl::Vector<unsigned long>::end() Line | Count | Source | 279 | 56.8k | T *end() { return data_ + size_; } |
bssl::Vector<std::__1::unique_ptr<bignum_st, bssl::internal::Deleter> >::end() Line | Count | Source | 279 | 61.1k | T *end() { return data_ + size_; } |
|
280 | 63.0k | const T *end() const { return data_ + size_; } Unexecuted instantiation: bssl::Vector<std::__1::unique_ptr<bssl::ECHServerConfig, bssl::internal::Deleter> >::end() const bssl::Vector<std::__1::unique_ptr<ssl_credential_st, bssl::internal::Deleter> >::end() const Line | Count | Source | 280 | 63.0k | const T *end() const { return data_ + size_; } |
|
281 | | |
282 | 621k | void clear() { |
283 | 621k | std::destroy_n(data_, size_); |
284 | 621k | OPENSSL_free(data_); |
285 | 621k | data_ = nullptr; |
286 | 621k | size_ = 0; |
287 | 621k | capacity_ = 0; |
288 | 621k | } bssl::Vector<std::__1::unique_ptr<bssl::ECHServerConfig, bssl::internal::Deleter> >::clear() Line | Count | Source | 282 | 13.6k | void clear() { | 283 | 13.6k | std::destroy_n(data_, size_); | 284 | 13.6k | OPENSSL_free(data_); | 285 | 13.6k | data_ = nullptr; | 286 | 13.6k | size_ = 0; | 287 | 13.6k | capacity_ = 0; | 288 | 13.6k | } |
bssl::Vector<bssl::ALPSConfig>::clear() Line | Count | Source | 282 | 121k | void clear() { | 283 | 121k | std::destroy_n(data_, size_); | 284 | 121k | OPENSSL_free(data_); | 285 | 121k | data_ = nullptr; | 286 | 121k | size_ = 0; | 287 | 121k | capacity_ = 0; | 288 | 121k | } |
bssl::Vector<std::__1::unique_ptr<ssl_credential_st, bssl::internal::Deleter> >::clear() Line | Count | Source | 282 | 126k | void clear() { | 283 | 126k | std::destroy_n(data_, size_); | 284 | 126k | OPENSSL_free(data_); | 285 | 126k | data_ = nullptr; | 286 | 126k | size_ = 0; | 287 | 126k | capacity_ = 0; | 288 | 126k | } |
bssl::Vector<bssl::CertCompressionAlg>::clear() Line | Count | Source | 282 | 4.86k | void clear() { | 283 | 4.86k | std::destroy_n(data_, size_); | 284 | 4.86k | OPENSSL_free(data_); | 285 | 4.86k | data_ = nullptr; | 286 | 4.86k | size_ = 0; | 287 | 4.86k | capacity_ = 0; | 288 | 4.86k | } |
bssl::Vector<unsigned long>::clear() Line | Count | Source | 282 | 175k | void clear() { | 283 | 175k | std::destroy_n(data_, size_); | 284 | 175k | OPENSSL_free(data_); | 285 | 175k | data_ = nullptr; | 286 | 175k | size_ = 0; | 287 | 175k | capacity_ = 0; | 288 | 175k | } |
bssl::Vector<std::__1::unique_ptr<bignum_st, bssl::internal::Deleter> >::clear() Line | Count | Source | 282 | 179k | void clear() { | 283 | 179k | std::destroy_n(data_, size_); | 284 | 179k | OPENSSL_free(data_); | 285 | 179k | data_ = nullptr; | 286 | 179k | size_ = 0; | 287 | 179k | capacity_ = 0; | 288 | 179k | } |
|
289 | | |
290 | 20.8M | void pop_back() { |
291 | 20.8M | BSSL_CHECK(size_ != 0); |
292 | 20.8M | std::destroy_at(&data_[size_ - 1]); |
293 | 20.8M | size_--; |
294 | 20.8M | } |
295 | | |
296 | | // Push adds |elem| at the end of the internal array, growing if necessary. It |
297 | | // returns false when allocation fails. |
298 | 21.2M | [[nodiscard]] bool Push(T elem) { |
299 | 21.2M | if (!MaybeGrow()) { |
300 | 0 | return false; |
301 | 0 | } |
302 | 21.2M | new (&data_[size_]) T(std::move(elem)); |
303 | 21.2M | size_++; |
304 | 21.2M | return true; |
305 | 21.2M | } bssl::Vector<std::__1::unique_ptr<bssl::ECHServerConfig, bssl::internal::Deleter> >::Push(std::__1::unique_ptr<bssl::ECHServerConfig, bssl::internal::Deleter>) Line | Count | Source | 298 | 6 | [[nodiscard]] bool Push(T elem) { | 299 | 6 | if (!MaybeGrow()) { | 300 | 0 | return false; | 301 | 0 | } | 302 | 6 | new (&data_[size_]) T(std::move(elem)); | 303 | 6 | size_++; | 304 | 6 | return true; | 305 | 6 | } |
Unexecuted instantiation: bssl::Vector<std::__1::unique_ptr<ssl_credential_st, bssl::internal::Deleter> >::Push(std::__1::unique_ptr<ssl_credential_st, bssl::internal::Deleter>) Unexecuted instantiation: bssl::Vector<bssl::ALPSConfig>::Push(bssl::ALPSConfig) Unexecuted instantiation: bssl::Vector<bssl::CertCompressionAlg>::Push(bssl::CertCompressionAlg) bssl::Vector<unsigned long>::Push(unsigned long) Line | Count | Source | 298 | 20.8M | [[nodiscard]] bool Push(T elem) { | 299 | 20.8M | if (!MaybeGrow()) { | 300 | 0 | return false; | 301 | 0 | } | 302 | 20.8M | new (&data_[size_]) T(std::move(elem)); | 303 | 20.8M | size_++; | 304 | 20.8M | return true; | 305 | 20.8M | } |
bssl::Vector<std::__1::unique_ptr<bignum_st, bssl::internal::Deleter> >::Push(std::__1::unique_ptr<bignum_st, bssl::internal::Deleter>) Line | Count | Source | 298 | 417k | [[nodiscard]] bool Push(T elem) { | 299 | 417k | if (!MaybeGrow()) { | 300 | 0 | return false; | 301 | 0 | } | 302 | 417k | new (&data_[size_]) T(std::move(elem)); | 303 | 417k | size_++; | 304 | 417k | return true; | 305 | 417k | } |
|
306 | | |
307 | | // CopyFrom replaces the contents of the array with a copy of |in|. It returns |
308 | | // true on success and false on allocation error. |
309 | | [[nodiscard]] bool CopyFrom(Span<const T> in) { |
310 | | Array<T> copy; |
311 | | if (!copy.CopyFrom(in)) { |
312 | | return false; |
313 | | } |
314 | | |
315 | | clear(); |
316 | | copy.Release(&data_, &size_); |
317 | | capacity_ = size_; |
318 | | return true; |
319 | | } |
320 | | |
321 | | private: |
322 | | // If there is no room for one more element, creates a new backing array with |
323 | | // double the size of the old one and copies elements over. |
324 | 21.2M | bool MaybeGrow() { |
325 | | // No need to grow if we have room for one more T. |
326 | 21.2M | if (size_ < capacity_) { |
327 | 21.1M | return true; |
328 | 21.1M | } |
329 | 118k | size_t new_capacity = kDefaultSize; |
330 | 118k | if (capacity_ > 0) { |
331 | | // Double the array's size if it's safe to do so. |
332 | 4.57k | if (capacity_ > SIZE_MAX / 2) { |
333 | 0 | OPENSSL_PUT_ERROR(CRYPTO, ERR_R_OVERFLOW); |
334 | 0 | return false; |
335 | 0 | } |
336 | 4.57k | new_capacity = capacity_ * 2; |
337 | 4.57k | } |
338 | 118k | if (new_capacity > SIZE_MAX / sizeof(T)) { |
339 | 0 | OPENSSL_PUT_ERROR(CRYPTO, ERR_R_OVERFLOW); |
340 | 0 | return false; |
341 | 0 | } |
342 | 118k | T *new_data = |
343 | 118k | reinterpret_cast<T *>(OPENSSL_malloc(new_capacity * sizeof(T))); |
344 | 118k | if (new_data == nullptr) { |
345 | 0 | return false; |
346 | 0 | } |
347 | 118k | size_t new_size = size_; |
348 | 118k | std::uninitialized_move(begin(), end(), new_data); |
349 | 118k | clear(); |
350 | 118k | data_ = new_data; |
351 | 118k | size_ = new_size; |
352 | 118k | capacity_ = new_capacity; |
353 | 118k | return true; |
354 | 118k | } bssl::Vector<std::__1::unique_ptr<bssl::ECHServerConfig, bssl::internal::Deleter> >::MaybeGrow() Line | Count | Source | 324 | 6 | bool MaybeGrow() { | 325 | | // No need to grow if we have room for one more T. | 326 | 6 | if (size_ < capacity_) { | 327 | 0 | return true; | 328 | 0 | } | 329 | 6 | size_t new_capacity = kDefaultSize; | 330 | 6 | if (capacity_ > 0) { | 331 | | // Double the array's size if it's safe to do so. | 332 | 0 | if (capacity_ > SIZE_MAX / 2) { | 333 | 0 | OPENSSL_PUT_ERROR(CRYPTO, ERR_R_OVERFLOW); | 334 | 0 | return false; | 335 | 0 | } | 336 | 0 | new_capacity = capacity_ * 2; | 337 | 0 | } | 338 | 6 | if (new_capacity > SIZE_MAX / sizeof(T)) { | 339 | 0 | OPENSSL_PUT_ERROR(CRYPTO, ERR_R_OVERFLOW); | 340 | 0 | return false; | 341 | 0 | } | 342 | 6 | T *new_data = | 343 | 6 | reinterpret_cast<T *>(OPENSSL_malloc(new_capacity * sizeof(T))); | 344 | 6 | if (new_data == nullptr) { | 345 | 0 | return false; | 346 | 0 | } | 347 | 6 | size_t new_size = size_; | 348 | 6 | std::uninitialized_move(begin(), end(), new_data); | 349 | 6 | clear(); | 350 | 6 | data_ = new_data; | 351 | 6 | size_ = new_size; | 352 | 6 | capacity_ = new_capacity; | 353 | 6 | return true; | 354 | 6 | } |
Unexecuted instantiation: bssl::Vector<std::__1::unique_ptr<ssl_credential_st, bssl::internal::Deleter> >::MaybeGrow() Unexecuted instantiation: bssl::Vector<bssl::ALPSConfig>::MaybeGrow() Unexecuted instantiation: bssl::Vector<bssl::CertCompressionAlg>::MaybeGrow() bssl::Vector<unsigned long>::MaybeGrow() Line | Count | Source | 324 | 20.8M | bool MaybeGrow() { | 325 | | // No need to grow if we have room for one more T. | 326 | 20.8M | if (size_ < capacity_) { | 327 | 20.7M | return true; | 328 | 20.7M | } | 329 | 56.8k | size_t new_capacity = kDefaultSize; | 330 | 56.8k | if (capacity_ > 0) { | 331 | | // Double the array's size if it's safe to do so. | 332 | 0 | if (capacity_ > SIZE_MAX / 2) { | 333 | 0 | OPENSSL_PUT_ERROR(CRYPTO, ERR_R_OVERFLOW); | 334 | 0 | return false; | 335 | 0 | } | 336 | 0 | new_capacity = capacity_ * 2; | 337 | 0 | } | 338 | 56.8k | if (new_capacity > SIZE_MAX / sizeof(T)) { | 339 | 0 | OPENSSL_PUT_ERROR(CRYPTO, ERR_R_OVERFLOW); | 340 | 0 | return false; | 341 | 0 | } | 342 | 56.8k | T *new_data = | 343 | 56.8k | reinterpret_cast<T *>(OPENSSL_malloc(new_capacity * sizeof(T))); | 344 | 56.8k | if (new_data == nullptr) { | 345 | 0 | return false; | 346 | 0 | } | 347 | 56.8k | size_t new_size = size_; | 348 | 56.8k | std::uninitialized_move(begin(), end(), new_data); | 349 | 56.8k | clear(); | 350 | 56.8k | data_ = new_data; | 351 | 56.8k | size_ = new_size; | 352 | 56.8k | capacity_ = new_capacity; | 353 | 56.8k | return true; | 354 | 56.8k | } |
bssl::Vector<std::__1::unique_ptr<bignum_st, bssl::internal::Deleter> >::MaybeGrow() Line | Count | Source | 324 | 417k | bool MaybeGrow() { | 325 | | // No need to grow if we have room for one more T. | 326 | 417k | if (size_ < capacity_) { | 327 | 356k | return true; | 328 | 356k | } | 329 | 61.1k | size_t new_capacity = kDefaultSize; | 330 | 61.1k | if (capacity_ > 0) { | 331 | | // Double the array's size if it's safe to do so. | 332 | 4.57k | if (capacity_ > SIZE_MAX / 2) { | 333 | 0 | OPENSSL_PUT_ERROR(CRYPTO, ERR_R_OVERFLOW); | 334 | 0 | return false; | 335 | 0 | } | 336 | 4.57k | new_capacity = capacity_ * 2; | 337 | 4.57k | } | 338 | 61.1k | if (new_capacity > SIZE_MAX / sizeof(T)) { | 339 | 0 | OPENSSL_PUT_ERROR(CRYPTO, ERR_R_OVERFLOW); | 340 | 0 | return false; | 341 | 0 | } | 342 | 61.1k | T *new_data = | 343 | 61.1k | reinterpret_cast<T *>(OPENSSL_malloc(new_capacity * sizeof(T))); | 344 | 61.1k | if (new_data == nullptr) { | 345 | 0 | return false; | 346 | 0 | } | 347 | 61.1k | size_t new_size = size_; | 348 | 61.1k | std::uninitialized_move(begin(), end(), new_data); | 349 | 61.1k | clear(); | 350 | 61.1k | data_ = new_data; | 351 | 61.1k | size_ = new_size; | 352 | 61.1k | capacity_ = new_capacity; | 353 | 61.1k | return true; | 354 | 61.1k | } |
|
355 | | |
356 | | // data_ is a pointer to |capacity_| objects of size |T|, the first |size_| of |
357 | | // which are constructed. |
358 | | T *data_ = nullptr; |
359 | | // |size_| is the number of elements stored in this Vector. |
360 | | size_t size_ = 0; |
361 | | // |capacity_| is the number of elements allocated in this Vector. |
362 | | size_t capacity_ = 0; |
363 | | // |kDefaultSize| is the default initial size of the backing array. |
364 | | static constexpr size_t kDefaultSize = 16; |
365 | | }; |
366 | | |
367 | | // A PackedSize is an integer that can store values from 0 to N, represented as |
368 | | // a minimal-width integer. |
369 | | template <size_t N> |
370 | | using PackedSize = std::conditional_t< |
371 | | N <= 0xff, uint8_t, |
372 | | std::conditional_t<N <= 0xffff, uint16_t, |
373 | | std::conditional_t<N <= 0xffffffff, uint32_t, size_t>>>; |
374 | | |
375 | | // An InplaceVector is like a Vector, but stores up to N elements inline in the |
376 | | // object. It is inspired by std::inplace_vector in C++26. |
377 | | template <typename T, size_t N> |
378 | | class InplaceVector { |
379 | | public: |
380 | 3.88M | InplaceVector() = default; bssl::InplaceVector<unsigned char, 48ul>::InplaceVector() Line | Count | Source | 380 | 2.26M | InplaceVector() = default; |
bssl::InplaceVector<unsigned char, 32ul>::InplaceVector() Line | Count | Source | 380 | 839k | InplaceVector() = default; |
bssl::InplaceVector<unsigned char, 12ul>::InplaceVector() Line | Count | Source | 380 | 646k | InplaceVector() = default; |
bssl::InplaceVector<bssl::DTLSRecordNumber, 32ul>::InplaceVector() Line | Count | Source | 380 | 43.4k | InplaceVector() = default; |
bssl::InplaceVector<bssl::DTLSSentRecord, 32ul>::InplaceVector() Line | Count | Source | 380 | 10.6k | InplaceVector() = default; |
bssl::InplaceVector<std::__1::unique_ptr<bssl::DTLSWriteEpoch, bssl::internal::Deleter>, 2ul>::InplaceVector() Line | Count | Source | 380 | 41.1k | InplaceVector() = default; |
bssl::InplaceVector<bssl::DTLSOutgoingMessage, 7ul>::InplaceVector() Line | Count | Source | 380 | 41.1k | InplaceVector() = default; |
|
381 | | InplaceVector(const InplaceVector &other) { *this = other; } |
382 | 47.3k | InplaceVector(InplaceVector &&other) { *this = std::move(other); } |
383 | 3.93M | ~InplaceVector() { clear(); } bssl::InplaceVector<unsigned char, 48ul>::~InplaceVector() Line | Count | Source | 383 | 2.31M | ~InplaceVector() { clear(); } |
bssl::InplaceVector<unsigned char, 32ul>::~InplaceVector() Line | Count | Source | 383 | 839k | ~InplaceVector() { clear(); } |
bssl::InplaceVector<unsigned char, 12ul>::~InplaceVector() Line | Count | Source | 383 | 646k | ~InplaceVector() { clear(); } |
bssl::InplaceVector<bssl::DTLSRecordNumber, 32ul>::~InplaceVector() Line | Count | Source | 383 | 43.4k | ~InplaceVector() { clear(); } |
bssl::InplaceVector<bssl::DTLSSentRecord, 32ul>::~InplaceVector() Line | Count | Source | 383 | 10.6k | ~InplaceVector() { clear(); } |
bssl::InplaceVector<std::__1::unique_ptr<bssl::DTLSWriteEpoch, bssl::internal::Deleter>, 2ul>::~InplaceVector() Line | Count | Source | 383 | 41.1k | ~InplaceVector() { clear(); } |
bssl::InplaceVector<bssl::DTLSOutgoingMessage, 7ul>::~InplaceVector() Line | Count | Source | 383 | 41.1k | ~InplaceVector() { clear(); } |
|
384 | 330k | InplaceVector &operator=(const InplaceVector &other) { |
385 | 330k | if (this != &other) { |
386 | 330k | CopyFrom(other); |
387 | 330k | } |
388 | 330k | return *this; |
389 | 330k | } bssl::InplaceVector<unsigned char, 32ul>::operator=(bssl::InplaceVector<unsigned char, 32ul> const&) Line | Count | Source | 384 | 226k | InplaceVector &operator=(const InplaceVector &other) { | 385 | 226k | if (this != &other) { | 386 | 226k | CopyFrom(other); | 387 | 226k | } | 388 | 226k | return *this; | 389 | 226k | } |
bssl::InplaceVector<unsigned char, 48ul>::operator=(bssl::InplaceVector<unsigned char, 48ul> const&) Line | Count | Source | 384 | 103k | InplaceVector &operator=(const InplaceVector &other) { | 385 | 103k | if (this != &other) { | 386 | 103k | CopyFrom(other); | 387 | 103k | } | 388 | 103k | return *this; | 389 | 103k | } |
|
390 | 129k | InplaceVector &operator=(InplaceVector &&other) { |
391 | 129k | clear(); |
392 | 129k | std::uninitialized_move(other.begin(), other.end(), data()); |
393 | 129k | size_ = other.size(); |
394 | 129k | return *this; |
395 | 129k | } |
396 | | |
397 | 1.30M | const T *data() const { return reinterpret_cast<const T *>(storage_); } bssl::InplaceVector<unsigned char, 48ul>::data() const Line | Count | Source | 397 | 400k | const T *data() const { return reinterpret_cast<const T *>(storage_); } |
bssl::InplaceVector<unsigned char, 32ul>::data() const Line | Count | Source | 397 | 904k | const T *data() const { return reinterpret_cast<const T *>(storage_); } |
Unexecuted instantiation: bssl::InplaceVector<unsigned char, 12ul>::data() const |
398 | 8.44M | T *data() { return reinterpret_cast<T *>(storage_); } bssl::InplaceVector<unsigned char, 12ul>::data() Line | Count | Source | 398 | 1.18M | T *data() { return reinterpret_cast<T *>(storage_); } |
bssl::InplaceVector<unsigned char, 32ul>::data() Line | Count | Source | 398 | 2.37M | T *data() { return reinterpret_cast<T *>(storage_); } |
bssl::InplaceVector<unsigned char, 48ul>::data() Line | Count | Source | 398 | 4.18M | T *data() { return reinterpret_cast<T *>(storage_); } |
bssl::InplaceVector<bssl::DTLSOutgoingMessage, 7ul>::data() Line | Count | Source | 398 | 243k | T *data() { return reinterpret_cast<T *>(storage_); } |
bssl::InplaceVector<bssl::DTLSRecordNumber, 32ul>::data() Line | Count | Source | 398 | 213k | T *data() { return reinterpret_cast<T *>(storage_); } |
bssl::InplaceVector<bssl::DTLSSentRecord, 32ul>::data() Line | Count | Source | 398 | 34.0k | T *data() { return reinterpret_cast<T *>(storage_); } |
bssl::InplaceVector<std::__1::unique_ptr<bssl::DTLSWriteEpoch, bssl::internal::Deleter>, 2ul>::data() Line | Count | Source | 398 | 214k | T *data() { return reinterpret_cast<T *>(storage_); } |
|
399 | 2.48M | size_t size() const { return size_; } bssl::InplaceVector<unsigned char, 12ul>::size() const Line | Count | Source | 399 | 241k | size_t size() const { return size_; } |
bssl::InplaceVector<unsigned char, 48ul>::size() const Line | Count | Source | 399 | 748k | size_t size() const { return size_; } |
bssl::InplaceVector<unsigned char, 32ul>::size() const Line | Count | Source | 399 | 968k | size_t size() const { return size_; } |
bssl::InplaceVector<bssl::DTLSOutgoingMessage, 7ul>::size() const Line | Count | Source | 399 | 182k | size_t size() const { return size_; } |
bssl::InplaceVector<bssl::DTLSRecordNumber, 32ul>::size() const Line | Count | Source | 399 | 280k | size_t size() const { return size_; } |
bssl::InplaceVector<bssl::DTLSSentRecord, 32ul>::size() const Line | Count | Source | 399 | 48.2k | size_t size() const { return size_; } |
bssl::InplaceVector<std::__1::unique_ptr<bssl::DTLSWriteEpoch, bssl::internal::Deleter>, 2ul>::size() const Line | Count | Source | 399 | 14.9k | size_t size() const { return size_; } |
|
400 | 1.84M | static constexpr size_t capacity() { return N; } bssl::InplaceVector<unsigned char, 32ul>::capacity() Line | Count | Source | 400 | 764k | static constexpr size_t capacity() { return N; } |
bssl::InplaceVector<unsigned char, 48ul>::capacity() Line | Count | Source | 400 | 634k | static constexpr size_t capacity() { return N; } |
bssl::InplaceVector<unsigned char, 12ul>::capacity() Line | Count | Source | 400 | 296k | static constexpr size_t capacity() { return N; } |
bssl::InplaceVector<bssl::DTLSOutgoingMessage, 7ul>::capacity() Line | Count | Source | 400 | 30.6k | static constexpr size_t capacity() { return N; } |
bssl::InplaceVector<bssl::DTLSRecordNumber, 32ul>::capacity() Line | Count | Source | 400 | 86.5k | static constexpr size_t capacity() { return N; } |
bssl::InplaceVector<bssl::DTLSSentRecord, 32ul>::capacity() Line | Count | Source | 400 | 20.1k | static constexpr size_t capacity() { return N; } |
bssl::InplaceVector<std::__1::unique_ptr<bssl::DTLSWriteEpoch, bssl::internal::Deleter>, 2ul>::capacity() Line | Count | Source | 400 | 8.26k | static constexpr size_t capacity() { return N; } |
|
401 | 167k | bool empty() const { return size_ == 0; } bssl::InplaceVector<unsigned char, 12ul>::empty() const Line | Count | Source | 401 | 86.5k | bool empty() const { return size_ == 0; } |
bssl::InplaceVector<unsigned char, 48ul>::empty() const Line | Count | Source | 401 | 2.00k | bool empty() const { return size_ == 0; } |
bssl::InplaceVector<unsigned char, 32ul>::empty() const Line | Count | Source | 401 | 63.1k | bool empty() const { return size_ == 0; } |
bssl::InplaceVector<bssl::DTLSOutgoingMessage, 7ul>::empty() const Line | Count | Source | 401 | 15.4k | bool empty() const { return size_ == 0; } |
|
402 | | |
403 | | const T &operator[](size_t i) const { |
404 | | BSSL_CHECK(i < size_); |
405 | | return data()[i]; |
406 | | } |
407 | 217k | T &operator[](size_t i) { |
408 | 217k | BSSL_CHECK(i < size_); |
409 | 217k | return data()[i]; |
410 | 217k | } bssl::InplaceVector<unsigned char, 12ul>::operator[](unsigned long) Line | Count | Source | 407 | 39.8k | T &operator[](size_t i) { | 408 | 39.8k | BSSL_CHECK(i < size_); | 409 | 39.8k | return data()[i]; | 410 | 39.8k | } |
bssl::InplaceVector<bssl::DTLSRecordNumber, 32ul>::operator[](unsigned long) Line | Count | Source | 407 | 61.2k | T &operator[](size_t i) { | 408 | 61.2k | BSSL_CHECK(i < size_); | 409 | 61.2k | return data()[i]; | 410 | 61.2k | } |
bssl::InplaceVector<bssl::DTLSSentRecord, 32ul>::operator[](unsigned long) Line | Count | Source | 407 | 3.30k | T &operator[](size_t i) { | 408 | 3.30k | BSSL_CHECK(i < size_); | 409 | 3.30k | return data()[i]; | 410 | 3.30k | } |
bssl::InplaceVector<std::__1::unique_ptr<bssl::DTLSWriteEpoch, bssl::internal::Deleter>, 2ul>::operator[](unsigned long) Line | Count | Source | 407 | 2.46k | T &operator[](size_t i) { | 408 | 2.46k | BSSL_CHECK(i < size_); | 409 | 2.46k | return data()[i]; | 410 | 2.46k | } |
bssl::InplaceVector<bssl::DTLSOutgoingMessage, 7ul>::operator[](unsigned long) Line | Count | Source | 407 | 110k | T &operator[](size_t i) { | 408 | 110k | BSSL_CHECK(i < size_); | 409 | 110k | return data()[i]; | 410 | 110k | } |
|
411 | | |
412 | | T &front() { |
413 | | BSSL_CHECK(size_ != 0); |
414 | | return data()[0]; |
415 | | } |
416 | | const T &front() const { |
417 | | BSSL_CHECK(size_ != 0); |
418 | | return data()[0]; |
419 | | } |
420 | | T &back() { |
421 | | BSSL_CHECK(size_ != 0); |
422 | | return data()[size_ - 1]; |
423 | | } |
424 | | const T &back() const { |
425 | | BSSL_CHECK(size_ != 0); |
426 | | return data()[size_ - 1]; |
427 | | } |
428 | | |
429 | 220k | T *begin() { return data(); } bssl::InplaceVector<bssl::DTLSRecordNumber, 32ul>::begin() Line | Count | Source | 429 | 4.73k | T *begin() { return data(); } |
bssl::InplaceVector<std::__1::unique_ptr<bssl::DTLSWriteEpoch, bssl::internal::Deleter>, 2ul>::begin() Line | Count | Source | 429 | 66.2k | T *begin() { return data(); } |
bssl::InplaceVector<bssl::DTLSOutgoingMessage, 7ul>::begin() Line | Count | Source | 429 | 20.4k | T *begin() { return data(); } |
bssl::InplaceVector<unsigned char, 48ul>::begin() Line | Count | Source | 429 | 129k | T *begin() { return data(); } |
|
430 | | const T *begin() const { return data(); } |
431 | 246k | T *end() { return data() + size_; } bssl::InplaceVector<bssl::DTLSRecordNumber, 32ul>::end() Line | Count | Source | 431 | 4.73k | T *end() { return data() + size_; } |
bssl::InplaceVector<std::__1::unique_ptr<bssl::DTLSWriteEpoch, bssl::internal::Deleter>, 2ul>::end() Line | Count | Source | 431 | 92.2k | T *end() { return data() + size_; } |
bssl::InplaceVector<bssl::DTLSOutgoingMessage, 7ul>::end() Line | Count | Source | 431 | 20.4k | T *end() { return data() + size_; } |
bssl::InplaceVector<unsigned char, 48ul>::end() Line | Count | Source | 431 | 129k | T *end() { return data() + size_; } |
|
432 | | const T *end() const { return data() + size_; } |
433 | | |
434 | 5.45M | void clear() { Shrink(0); } bssl::InplaceVector<unsigned char, 48ul>::clear() Line | Count | Source | 434 | 2.94M | void clear() { Shrink(0); } |
bssl::InplaceVector<unsigned char, 32ul>::clear() Line | Count | Source | 434 | 1.49M | void clear() { Shrink(0); } |
bssl::InplaceVector<unsigned char, 12ul>::clear() Line | Count | Source | 434 | 844k | void clear() { Shrink(0); } |
bssl::InplaceVector<bssl::DTLSRecordNumber, 32ul>::clear() Line | Count | Source | 434 | 55.9k | void clear() { Shrink(0); } |
bssl::InplaceVector<bssl::DTLSSentRecord, 32ul>::clear() Line | Count | Source | 434 | 10.6k | void clear() { Shrink(0); } |
bssl::InplaceVector<bssl::DTLSOutgoingMessage, 7ul>::clear() Line | Count | Source | 434 | 61.8k | void clear() { Shrink(0); } |
bssl::InplaceVector<std::__1::unique_ptr<bssl::DTLSWriteEpoch, bssl::internal::Deleter>, 2ul>::clear() Line | Count | Source | 434 | 41.1k | void clear() { Shrink(0); } |
|
435 | | |
436 | | void pop_back() { |
437 | | BSSL_CHECK(size_ != 0); |
438 | | Shrink(size_ - 1); |
439 | | } |
440 | | |
441 | | // Shrink resizes the vector to |new_size|, which must not be larger than the |
442 | | // current size. Unlike |Resize|, this can be called when |T| is not |
443 | | // default-constructible. |
444 | 5.45M | void Shrink(size_t new_size) { |
445 | 5.45M | BSSL_CHECK(new_size <= size_); |
446 | 5.45M | std::destroy_n(data() + new_size, size_ - new_size); |
447 | 5.45M | size_ = static_cast<PackedSize<N>>(new_size); |
448 | 5.45M | } bssl::InplaceVector<unsigned char, 32ul>::Shrink(unsigned long) Line | Count | Source | 444 | 1.49M | void Shrink(size_t new_size) { | 445 | 1.49M | BSSL_CHECK(new_size <= size_); | 446 | 1.49M | std::destroy_n(data() + new_size, size_ - new_size); | 447 | 1.49M | size_ = static_cast<PackedSize<N>>(new_size); | 448 | 1.49M | } |
bssl::InplaceVector<unsigned char, 48ul>::Shrink(unsigned long) Line | Count | Source | 444 | 2.94M | void Shrink(size_t new_size) { | 445 | 2.94M | BSSL_CHECK(new_size <= size_); | 446 | 2.94M | std::destroy_n(data() + new_size, size_ - new_size); | 447 | 2.94M | size_ = static_cast<PackedSize<N>>(new_size); | 448 | 2.94M | } |
bssl::InplaceVector<unsigned char, 12ul>::Shrink(unsigned long) Line | Count | Source | 444 | 844k | void Shrink(size_t new_size) { | 445 | 844k | BSSL_CHECK(new_size <= size_); | 446 | 844k | std::destroy_n(data() + new_size, size_ - new_size); | 447 | 844k | size_ = static_cast<PackedSize<N>>(new_size); | 448 | 844k | } |
bssl::InplaceVector<bssl::DTLSRecordNumber, 32ul>::Shrink(unsigned long) Line | Count | Source | 444 | 55.9k | void Shrink(size_t new_size) { | 445 | 55.9k | BSSL_CHECK(new_size <= size_); | 446 | 55.9k | std::destroy_n(data() + new_size, size_ - new_size); | 447 | 55.9k | size_ = static_cast<PackedSize<N>>(new_size); | 448 | 55.9k | } |
bssl::InplaceVector<bssl::DTLSSentRecord, 32ul>::Shrink(unsigned long) Line | Count | Source | 444 | 10.6k | void Shrink(size_t new_size) { | 445 | 10.6k | BSSL_CHECK(new_size <= size_); | 446 | 10.6k | std::destroy_n(data() + new_size, size_ - new_size); | 447 | 10.6k | size_ = static_cast<PackedSize<N>>(new_size); | 448 | 10.6k | } |
bssl::InplaceVector<bssl::DTLSOutgoingMessage, 7ul>::Shrink(unsigned long) Line | Count | Source | 444 | 61.8k | void Shrink(size_t new_size) { | 445 | 61.8k | BSSL_CHECK(new_size <= size_); | 446 | 61.8k | std::destroy_n(data() + new_size, size_ - new_size); | 447 | 61.8k | size_ = static_cast<PackedSize<N>>(new_size); | 448 | 61.8k | } |
bssl::InplaceVector<std::__1::unique_ptr<bssl::DTLSWriteEpoch, bssl::internal::Deleter>, 2ul>::Shrink(unsigned long) Line | Count | Source | 444 | 45.3k | void Shrink(size_t new_size) { | 445 | 45.3k | BSSL_CHECK(new_size <= size_); | 446 | 45.3k | std::destroy_n(data() + new_size, size_ - new_size); | 447 | 45.3k | size_ = static_cast<PackedSize<N>>(new_size); | 448 | 45.3k | } |
|
449 | | |
450 | | // TryResize resizes the vector to |new_size| and returns true, or returns |
451 | | // false if |new_size| is too large. Any newly-added elements are |
452 | | // value-initialized. |
453 | 6.55k | [[nodiscard]] bool TryResize(size_t new_size) { |
454 | 6.55k | if (new_size <= size_) { |
455 | 0 | Shrink(new_size); |
456 | 0 | return true; |
457 | 0 | } |
458 | 6.55k | if (new_size > capacity()) { |
459 | 0 | return false; |
460 | 0 | } |
461 | 6.55k | std::uninitialized_value_construct_n(data() + size_, new_size - size_); |
462 | 6.55k | size_ = static_cast<PackedSize<N>>(new_size); |
463 | 6.55k | return true; |
464 | 6.55k | } |
465 | | |
466 | | // TryResizeForOverwrite behaves like |TryResize|, but newly-added elements |
467 | | // are default-initialized, so POD types may contain uninitialized values that |
468 | | // the caller is responsible for filling in. |
469 | 243k | [[nodiscard]] bool TryResizeForOverwrite(size_t new_size) { |
470 | 243k | if (new_size <= size_) { |
471 | 168 | Shrink(new_size); |
472 | 168 | return true; |
473 | 168 | } |
474 | 243k | if (new_size > capacity()) { |
475 | 0 | return false; |
476 | 0 | } |
477 | 243k | std::uninitialized_default_construct_n(data() + size_, new_size - size_); |
478 | 243k | size_ = static_cast<PackedSize<N>>(new_size); |
479 | 243k | return true; |
480 | 243k | } bssl::InplaceVector<unsigned char, 32ul>::TryResizeForOverwrite(unsigned long) Line | Count | Source | 469 | 111k | [[nodiscard]] bool TryResizeForOverwrite(size_t new_size) { | 470 | 111k | if (new_size <= size_) { | 471 | 46 | Shrink(new_size); | 472 | 46 | return true; | 473 | 46 | } | 474 | 111k | if (new_size > capacity()) { | 475 | 0 | return false; | 476 | 0 | } | 477 | 111k | std::uninitialized_default_construct_n(data() + size_, new_size - size_); | 478 | 111k | size_ = static_cast<PackedSize<N>>(new_size); | 479 | 111k | return true; | 480 | 111k | } |
bssl::InplaceVector<unsigned char, 48ul>::TryResizeForOverwrite(unsigned long) Line | Count | Source | 469 | 131k | [[nodiscard]] bool TryResizeForOverwrite(size_t new_size) { | 470 | 131k | if (new_size <= size_) { | 471 | 122 | Shrink(new_size); | 472 | 122 | return true; | 473 | 122 | } | 474 | 131k | if (new_size > capacity()) { | 475 | 0 | return false; | 476 | 0 | } | 477 | 131k | std::uninitialized_default_construct_n(data() + size_, new_size - size_); | 478 | 131k | size_ = static_cast<PackedSize<N>>(new_size); | 479 | 131k | return true; | 480 | 131k | } |
|
481 | | |
482 | | // TryCopyFrom sets the vector to a copy of |in| and returns true, or returns |
483 | | // false if |in| is too large. |
484 | 1.34M | [[nodiscard]] bool TryCopyFrom(Span<const T> in) { |
485 | 1.34M | if (in.size() > capacity()) { |
486 | 1.34k | return false; |
487 | 1.34k | } |
488 | 1.34M | clear(); |
489 | 1.34M | std::uninitialized_copy(in.begin(), in.end(), data()); |
490 | 1.34M | size_ = in.size(); |
491 | 1.34M | return true; |
492 | 1.34M | } bssl::InplaceVector<unsigned char, 48ul>::TryCopyFrom(bssl::Span<unsigned char const>) Line | Count | Source | 484 | 496k | [[nodiscard]] bool TryCopyFrom(Span<const T> in) { | 485 | 496k | if (in.size() > capacity()) { | 486 | 31 | return false; | 487 | 31 | } | 488 | 495k | clear(); | 489 | 495k | std::uninitialized_copy(in.begin(), in.end(), data()); | 490 | 495k | size_ = in.size(); | 491 | 495k | return true; | 492 | 496k | } |
bssl::InplaceVector<unsigned char, 12ul>::TryCopyFrom(bssl::Span<unsigned char const>) Line | Count | Source | 484 | 197k | [[nodiscard]] bool TryCopyFrom(Span<const T> in) { | 485 | 197k | if (in.size() > capacity()) { | 486 | 0 | return false; | 487 | 0 | } | 488 | 197k | clear(); | 489 | 197k | std::uninitialized_copy(in.begin(), in.end(), data()); | 490 | 197k | size_ = in.size(); | 491 | 197k | return true; | 492 | 197k | } |
bssl::InplaceVector<unsigned char, 32ul>::TryCopyFrom(bssl::Span<unsigned char const>) Line | Count | Source | 484 | 652k | [[nodiscard]] bool TryCopyFrom(Span<const T> in) { | 485 | 652k | if (in.size() > capacity()) { | 486 | 1.31k | return false; | 487 | 1.31k | } | 488 | 651k | clear(); | 489 | 651k | std::uninitialized_copy(in.begin(), in.end(), data()); | 490 | 651k | size_ = in.size(); | 491 | 651k | return true; | 492 | 652k | } |
|
493 | | |
494 | | // TryPushBack appends |val| to the vector and returns a pointer to the |
495 | | // newly-inserted value, or nullptr if the vector is at capacity. |
496 | 145k | [[nodiscard]] T *TryPushBack(T val) { |
497 | 145k | if (size() >= capacity()) { |
498 | 0 | return nullptr; |
499 | 0 | } |
500 | 145k | T *ret = &data()[size_]; |
501 | 145k | new (ret) T(std::move(val)); |
502 | 145k | size_++; |
503 | 145k | return ret; |
504 | 145k | } bssl::InplaceVector<bssl::DTLSOutgoingMessage, 7ul>::TryPushBack(bssl::DTLSOutgoingMessage) Line | Count | Source | 496 | 30.6k | [[nodiscard]] T *TryPushBack(T val) { | 497 | 30.6k | if (size() >= capacity()) { | 498 | 0 | return nullptr; | 499 | 0 | } | 500 | 30.6k | T *ret = &data()[size_]; | 501 | 30.6k | new (ret) T(std::move(val)); | 502 | 30.6k | size_++; | 503 | 30.6k | return ret; | 504 | 30.6k | } |
bssl::InplaceVector<bssl::DTLSRecordNumber, 32ul>::TryPushBack(bssl::DTLSRecordNumber) Line | Count | Source | 496 | 86.5k | [[nodiscard]] T *TryPushBack(T val) { | 497 | 86.5k | if (size() >= capacity()) { | 498 | 0 | return nullptr; | 499 | 0 | } | 500 | 86.5k | T *ret = &data()[size_]; | 501 | 86.5k | new (ret) T(std::move(val)); | 502 | 86.5k | size_++; | 503 | 86.5k | return ret; | 504 | 86.5k | } |
bssl::InplaceVector<bssl::DTLSSentRecord, 32ul>::TryPushBack(bssl::DTLSSentRecord) Line | Count | Source | 496 | 20.1k | [[nodiscard]] T *TryPushBack(T val) { | 497 | 20.1k | if (size() >= capacity()) { | 498 | 0 | return nullptr; | 499 | 0 | } | 500 | 20.1k | T *ret = &data()[size_]; | 501 | 20.1k | new (ret) T(std::move(val)); | 502 | 20.1k | size_++; | 503 | 20.1k | return ret; | 504 | 20.1k | } |
bssl::InplaceVector<std::__1::unique_ptr<bssl::DTLSWriteEpoch, bssl::internal::Deleter>, 2ul>::TryPushBack(std::__1::unique_ptr<bssl::DTLSWriteEpoch, bssl::internal::Deleter>) Line | Count | Source | 496 | 8.26k | [[nodiscard]] T *TryPushBack(T val) { | 497 | 8.26k | if (size() >= capacity()) { | 498 | 0 | return nullptr; | 499 | 0 | } | 500 | 8.26k | T *ret = &data()[size_]; | 501 | 8.26k | new (ret) T(std::move(val)); | 502 | 8.26k | size_++; | 503 | 8.26k | return ret; | 504 | 8.26k | } |
|
505 | | |
506 | | // The following methods behave like their |Try*| counterparts, but abort the |
507 | | // program on failure. |
508 | 6.55k | void Resize(size_t size) { BSSL_CHECK(TryResize(size)); } |
509 | 243k | void ResizeForOverwrite(size_t size) { |
510 | 243k | BSSL_CHECK(TryResizeForOverwrite(size)); |
511 | 243k | } bssl::InplaceVector<unsigned char, 32ul>::ResizeForOverwrite(unsigned long) Line | Count | Source | 509 | 111k | void ResizeForOverwrite(size_t size) { | 510 | 111k | BSSL_CHECK(TryResizeForOverwrite(size)); | 511 | 111k | } |
bssl::InplaceVector<unsigned char, 48ul>::ResizeForOverwrite(unsigned long) Line | Count | Source | 509 | 131k | void ResizeForOverwrite(size_t size) { | 510 | 131k | BSSL_CHECK(TryResizeForOverwrite(size)); | 511 | 131k | } |
|
512 | 648k | void CopyFrom(Span<const T> in) { BSSL_CHECK(TryCopyFrom(in)); } bssl::InplaceVector<unsigned char, 12ul>::CopyFrom(bssl::Span<unsigned char const>) Line | Count | Source | 512 | 146k | void CopyFrom(Span<const T> in) { BSSL_CHECK(TryCopyFrom(in)); } |
bssl::InplaceVector<unsigned char, 32ul>::CopyFrom(bssl::Span<unsigned char const>) Line | Count | Source | 512 | 292k | void CopyFrom(Span<const T> in) { BSSL_CHECK(TryCopyFrom(in)); } |
bssl::InplaceVector<unsigned char, 48ul>::CopyFrom(bssl::Span<unsigned char const>) Line | Count | Source | 512 | 209k | void CopyFrom(Span<const T> in) { BSSL_CHECK(TryCopyFrom(in)); } |
|
513 | 114k | T &PushBack(T val) { |
514 | 114k | T *ret = TryPushBack(std::move(val)); |
515 | 114k | BSSL_CHECK(ret != nullptr); |
516 | 114k | return *ret; |
517 | 114k | } bssl::InplaceVector<bssl::DTLSRecordNumber, 32ul>::PushBack(bssl::DTLSRecordNumber) Line | Count | Source | 513 | 86.5k | T &PushBack(T val) { | 514 | 86.5k | T *ret = TryPushBack(std::move(val)); | 515 | 86.5k | BSSL_CHECK(ret != nullptr); | 516 | 86.5k | return *ret; | 517 | 86.5k | } |
bssl::InplaceVector<bssl::DTLSSentRecord, 32ul>::PushBack(bssl::DTLSSentRecord) Line | Count | Source | 513 | 20.1k | T &PushBack(T val) { | 514 | 20.1k | T *ret = TryPushBack(std::move(val)); | 515 | 20.1k | BSSL_CHECK(ret != nullptr); | 516 | 20.1k | return *ret; | 517 | 20.1k | } |
bssl::InplaceVector<std::__1::unique_ptr<bssl::DTLSWriteEpoch, bssl::internal::Deleter>, 2ul>::PushBack(std::__1::unique_ptr<bssl::DTLSWriteEpoch, bssl::internal::Deleter>) Line | Count | Source | 513 | 8.26k | T &PushBack(T val) { | 514 | 8.26k | T *ret = TryPushBack(std::move(val)); | 515 | 8.26k | BSSL_CHECK(ret != nullptr); | 516 | 8.26k | return *ret; | 517 | 8.26k | } |
|
518 | | |
519 | | template <typename Pred> |
520 | 30.2k | void EraseIf(Pred pred) { |
521 | | // See if anything needs to be erased at all. This avoids a self-move. |
522 | 30.2k | auto iter = std::find_if(begin(), end(), pred); |
523 | 30.2k | if (iter == end()) { |
524 | 26.0k | return; |
525 | 26.0k | } |
526 | | |
527 | | // Elements before the first to be erased may be left as-is. |
528 | 4.20k | size_t new_size = iter - begin(); |
529 | | // Swap all subsequent elements in if they are to be kept. |
530 | 6.65k | for (size_t i = new_size + 1; i < size(); i++) { |
531 | 2.44k | if (!pred((*this)[i])) { |
532 | 10 | (*this)[new_size] = std::move((*this)[i]); |
533 | 10 | new_size++; |
534 | 10 | } |
535 | 2.44k | } |
536 | | |
537 | 4.20k | Shrink(new_size); |
538 | 4.20k | } |
539 | | |
540 | | private: |
541 | | alignas(T) char storage_[sizeof(T[N])]; |
542 | | PackedSize<N> size_ = 0; |
543 | | }; |
544 | | |
545 | | |
546 | | BSSL_NAMESPACE_END |
547 | | |
548 | | #endif // OPENSSL_HEADER_CRYPTO_MEM_INTERNAL_H |