diff options
-rw-r--r-- | src/lib/entropy/entropy_src.h | 4 | ||||
-rw-r--r-- | src/lib/entropy/entropy_srcs.cpp | 16 |
2 files changed, 4 insertions, 16 deletions
diff --git a/src/lib/entropy/entropy_src.h b/src/lib/entropy/entropy_src.h index 3b91847d8..33fdbc3e6 100644 --- a/src/lib/entropy/entropy_src.h +++ b/src/lib/entropy/entropy_src.h @@ -68,10 +68,8 @@ class BOTAN_PUBLIC_API(2,0) Entropy_Sources final Entropy_Sources() {} explicit Entropy_Sources(const std::vector<std::string>& sources); - - ~Entropy_Sources(); private: - std::vector<Entropy_Source*> m_srcs; + std::vector<std::unique_ptr<Entropy_Source>> m_srcs; }; } diff --git a/src/lib/entropy/entropy_srcs.cpp b/src/lib/entropy/entropy_srcs.cpp index 69e593fb9..c05ff9495 100644 --- a/src/lib/entropy/entropy_srcs.cpp +++ b/src/lib/entropy/entropy_srcs.cpp @@ -130,7 +130,7 @@ void Entropy_Sources::add_source(std::unique_ptr<Entropy_Source> src) { if(src.get()) { - m_srcs.push_back(src.release()); + m_srcs.push_back(std::move(src)); } } @@ -154,9 +154,9 @@ size_t Entropy_Sources::poll(RandomNumberGenerator& rng, size_t bits_collected = 0; - for(Entropy_Source* src : m_srcs) + for(size_t i = 0; i != m_srcs.size(); ++i) { - bits_collected += src->poll(rng); + bits_collected += m_srcs[i]->poll(rng); if (bits_collected >= poll_bits || clock::now() > deadline) break; @@ -186,16 +186,6 @@ Entropy_Sources::Entropy_Sources(const std::vector<std::string>& sources) } } -Entropy_Sources::~Entropy_Sources() - { - for(size_t i = 0; i != m_srcs.size(); ++i) - { - delete m_srcs[i]; - m_srcs[i] = nullptr; - } - m_srcs.clear(); - } - Entropy_Sources& Entropy_Sources::global_sources() { static Entropy_Sources global_entropy_sources(BOTAN_ENTROPY_DEFAULT_SOURCES); |