summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Majer <amajer@suse.de>2016-12-21 11:16:38 +0100
committerSam Roberts <vieuxtech@gmail.com>2017-01-24 13:44:50 -0800
commit3ada5ae641673219a0623909b8a2a08fa201cd9e (patch)
tree3253d7b10b65a8bc338fbdd148dae091f34c3298
parent3e9c8ef53b66a788e90d116391da61fee32323a7 (diff)
downloadnode-new-3ada5ae641673219a0623909b8a2a08fa201cd9e.tar.gz
crypto: do not use pointers to std::vector
The pointer to std::vector is unnecessary, so replace it with standard instance. Also, make the for() loop more readable by using actual type instead of inferred - there is no readability benefit here from obfuscating the type. PR-URL: https://github.com/nodejs/node/pull/8334 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
-rw-r--r--src/node_crypto.cc10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index ea3ec00ca2..41bd8e27b3 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -123,7 +123,7 @@ const char* const root_certs[] = {
std::string extra_root_certs_file; // NOLINT(runtime/string)
X509_STORE* root_cert_store;
-std::vector<X509*>* root_certs_vector;
+std::vector<X509*> root_certs_vector;
// Just to generate static methods
template class SSLWrap<TLSWrap>;
@@ -693,9 +693,7 @@ static int X509_up_ref(X509* cert) {
static X509_STORE* NewRootCertStore() {
- if (!root_certs_vector) {
- root_certs_vector = new std::vector<X509*>;
-
+ if (root_certs_vector.empty()) {
for (size_t i = 0; i < arraysize(root_certs); i++) {
BIO* bp = NodeBIO::NewFixed(root_certs[i], strlen(root_certs[i]));
X509 *x509 = PEM_read_bio_X509(bp, nullptr, CryptoPemCallback, nullptr);
@@ -704,12 +702,12 @@ static X509_STORE* NewRootCertStore() {
// Parse errors from the built-in roots are fatal.
CHECK_NE(x509, nullptr);
- root_certs_vector->push_back(x509);
+ root_certs_vector.push_back(x509);
}
}
X509_STORE* store = X509_STORE_new();
- for (auto& cert : *root_certs_vector) {
+ for (X509 *cert : root_certs_vector) {
X509_up_ref(cert);
X509_STORE_add_cert(store, cert);
}