diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/algo_factory/algo_cache.h | 13 | ||||
-rw-r--r-- | src/algo_factory/algo_factory.cpp | 5 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/algo_factory/algo_cache.h b/src/algo_factory/algo_cache.h index 376af130b..4606cac23 100644 --- a/src/algo_factory/algo_cache.h +++ b/src/algo_factory/algo_cache.h @@ -63,11 +63,16 @@ class Algorithm_Cache std::vector<std::string> providers_of(const std::string& algo_name); /** + * Clear the cache + */ + void clear_cache(); + + /** * Constructor * @param m a mutex to serialize internal access */ Algorithm_Cache(Mutex* m) : mutex(m) {} - ~Algorithm_Cache(); + ~Algorithm_Cache() { clear_cache(); delete mutex; } private: typedef typename std::map<std::string, std::map<std::string, T*> >::iterator algorithms_iterator; @@ -215,10 +220,10 @@ void Algorithm_Cache<T>::set_preferred_provider(const std::string& algo_spec, } /* -* Algorithm_Cache<T> Destructor +* Clear out the cache */ template<typename T> -Algorithm_Cache<T>::~Algorithm_Cache() +void Algorithm_Cache<T>::clear_cache() { algorithms_iterator algo = algorithms.begin(); @@ -235,7 +240,7 @@ Algorithm_Cache<T>::~Algorithm_Cache() ++algo; } - delete mutex; + algorithms.clear(); } } diff --git a/src/algo_factory/algo_factory.cpp b/src/algo_factory/algo_factory.cpp index 526ad1beb..16ac589a1 100644 --- a/src/algo_factory/algo_factory.cpp +++ b/src/algo_factory/algo_factory.cpp @@ -110,6 +110,11 @@ Algorithm_Factory::~Algorithm_Factory() void Algorithm_Factory::add_engine(Engine* engine) { + block_cipher_cache->clear_cache(); + stream_cipher_cache->clear_cache(); + hash_cache->clear_cache(); + mac_cache->clear_cache(); + engines.push_back(engine); } |