diff options
author | David Benjamin <davidben@chromium.org> | 2015-11-21 11:00:50 +0300 |
---|---|---|
committer | Adam Langley <alangley@gmail.com> | 2016-01-28 03:52:37 +0300 |
commit | 4f6acaf0da359e2c00d20d3553ad8ddd020368a1 (patch) | |
tree | 55d77973777f06f9c112842854cb265e545f7b62 /crypto/evp | |
parent | c3774c11876d4abc98651dd036a1c3301960b10b (diff) |
Use more C++11 features.
Finally, we can stick ScopedFOO in containers.
Change-Id: I3ed166575822af9f182e8be8f4db723e1f08ea31
Reviewed-on: https://boringssl-review.googlesource.com/6553
Reviewed-by: Adam Langley <alangley@gmail.com>
Diffstat (limited to 'crypto/evp')
-rw-r--r-- | crypto/evp/evp_test.cc | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/crypto/evp/evp_test.cc b/crypto/evp/evp_test.cc index 7fedc152..83906546 100644 --- a/crypto/evp/evp_test.cc +++ b/crypto/evp/evp_test.cc @@ -63,6 +63,7 @@ #include <map> #include <string> +#include <utility> #include <vector> #if defined(_MSC_VER) @@ -103,7 +104,7 @@ static const EVP_MD *GetDigest(FileTest *t, const std::string &name) { return nullptr; } -using KeyMap = std::map<std::string, EVP_PKEY*>; +using KeyMap = std::map<std::string, ScopedEVP_PKEY>; // ImportPrivateKey evaluates a PrivateKey test in |t| and writes the resulting // private key to |key_map|. @@ -123,7 +124,7 @@ static bool ImportPrivateKey(FileTest *t, KeyMap *key_map) { t->PrintLine("Error reading private key."); return false; } - (*key_map)[key_name] = pkey.release(); + (*key_map)[key_name] = std::move(pkey); return true; } @@ -156,7 +157,7 @@ static bool TestEVP(FileTest *t, void *arg) { t->PrintLine("Could not find key '%s'.", key_name.c_str()); return false; } - EVP_PKEY *key = (*key_map)[key_name]; + EVP_PKEY *key = (*key_map)[key_name].get(); std::vector<uint8_t> input, output; if (!t->GetBytes(&input, "Input") || @@ -212,11 +213,5 @@ int main(int argc, char **argv) { } KeyMap map; - int ret = FileTestMain(TestEVP, &map, argv[1]); - // TODO(davidben): When we can rely on a move-aware std::map, make KeyMap a - // map of ScopedEVP_PKEY instead. - for (const auto &pair : map) { - EVP_PKEY_free(pair.second); - } - return ret; + return FileTestMain(TestEVP, &map, argv[1]); } |