aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/base
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2015-09-10 01:45:47 -0400
committerJack Lloyd <[email protected]>2015-09-10 01:45:47 -0400
commitd21de17f070863c7e0b7e8d254eb35689001a53a (patch)
tree2627df5d3c911a56dea6a56aeca693a73d66f85e /src/lib/base
parenta96a7b79662f5045f0810dfa5d5cb4ebbd04ae42 (diff)
Fix static lib registration for block, hash, mac, stream, kdf
The support problems from having static libraries not work in the obvious way will be endless trouble. Instead have each set of registrations tag along in a source file for the basic type, at the cost of some extra ifdefs. On shared libs this is harmless - everything is going into the shared object anyway. With static libs, this means pulling in a single block cipher pulls in the text of all the them. But that's still strictly better than the amalgamation (which is really pulling in everything), and it works (unlike status quo).
Diffstat (limited to 'src/lib/base')
-rw-r--r--src/lib/base/algo_registry.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/base/algo_registry.h b/src/lib/base/algo_registry.h
index 498021194..8151551d3 100644
--- a/src/lib/base/algo_registry.h
+++ b/src/lib/base/algo_registry.h
@@ -35,7 +35,8 @@ class Algo_Registry
void add(const std::string& name, const std::string& provider, maker_fn fn, byte pref)
{
std::unique_lock<std::mutex> lock(m_mutex);
- m_algo_info[name].add_provider(provider, fn, pref);
+ if(!m_algo_info[name].add_provider(provider, fn, pref))
+ throw std::runtime_error("Duplicated registration of " + name + "/" + provider);
}
std::vector<std::string> providers_of(const Spec& spec)
@@ -102,13 +103,14 @@ class Algo_Registry
struct Algo_Info
{
public:
- void add_provider(const std::string& provider, maker_fn fn, byte pref)
+ bool add_provider(const std::string& provider, maker_fn fn, byte pref)
{
if(m_maker_fns.count(provider) > 0)
- throw std::runtime_error("Duplicated registration of '" + provider + "'");
+ return false;
m_maker_fns[provider] = fn;
m_prefs.insert(std::make_pair(pref, provider));
+ return true;
}
std::vector<std::string> providers() const