The unified diff between revisions [3a6266cf..] and [dc8ee1c8..] is displayed below. It can also be downloaded as a raw diff.

#
#
# patch "include/engine.h"
#  from [cbcfaa56101c7005b90835de646259029bbbc544]
#    to [20654be095cb727e6e4c850306e286e47fe7699f]
#
# patch "src/eng_base.cpp"
#  from [fc4e58e33c433517a4e519a9a9db3b7e7d9feb40]
#    to [59ac5ffe7de58b7e7601db17dc06196daa57eef0]
#
============================================================
--- include/engine.h	cbcfaa56101c7005b90835de646259029bbbc544
+++ include/engine.h	20654be095cb727e6e4c850306e286e47fe7699f
@@ -28,7 +28,7 @@ class Engine
          {
          public:
             virtual T* get(const std::string&) const = 0;
-            virtual void add(T* algo) const = 0;
+            virtual void add(T* algo, const std::string& = "") const = 0;
             virtual ~Algorithm_Cache() {}
          };

@@ -75,14 +75,18 @@ class Engine
          find_bc_pad(const std::string&) const;

       template<typename T>
-      T* lookup_algo(const Algorithm_Cache<T>* cache,
-                     const std::string& name,
-                     const Engine* engine,
-                     T* (Engine::*find)(const std::string& name) const) const
+      const T* lookup_algo(const Algorithm_Cache<T>* cache,
+                           const std::string& name,
+                           const Engine* engine,
+                           T* (Engine::*find)(const std::string&) const) const
          {
          T* algo = cache->get(name);
          if(!algo)
-            cache->add(algo = (engine->*find)(name));
+            {
+            algo = (engine->*find)(name);
+            if(algo)
+               cache->add(algo, name);
+            }
          return algo;
          }

============================================================
--- src/eng_base.cpp	fc4e58e33c433517a4e519a9a9db3b7e7d9feb40
+++ src/eng_base.cpp	59ac5ffe7de58b7e7601db17dc06196daa57eef0
@@ -25,17 +25,19 @@ class Algorithm_Cache_Impl : public Engi
          return search_map(mappings, name);
          }

-      void add(T* algo) const
+      void add(T* algo, const std::string& index_name = "") const
          {
          if(!algo)
             return;

          Mutex_Holder lock(mutex);

-         const std::string algo_name = algo->name();
-         if(mappings.find(algo_name) != mappings.end())
-            delete mappings[algo_name];
-         mappings[algo_name] = algo;
+         const std::string name =
+            (index_name != "" ? index_name : algo->name());
+
+         if(mappings.find(name) != mappings.end())
+            delete mappings[name];
+         mappings[name] = algo;
          }

       Algorithm_Cache_Impl()
@@ -59,7 +61,6 @@ class Algorithm_Cache_Impl : public Engi
       mutable std::map<std::string, T*> mappings;
    };

-
 }

 /*************************************************