diff options
author | lloyd <[email protected]> | 2010-03-10 15:30:33 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-03-10 15:30:33 +0000 |
commit | da6015b3c61f0834231ff2636e6957a89f9431d3 (patch) | |
tree | a62214d2e0d167e940df92fd9df4db8e9e428c93 /src/libstate | |
parent | 3bff865adb76f088ed4e3014992bdd0dec2ac878 (diff) |
Remove the base/default_allocator option, instead save as a per-libstate
variable directly.
Diffstat (limited to 'src/libstate')
-rw-r--r-- | src/libstate/libstate.cpp | 17 | ||||
-rw-r--r-- | src/libstate/libstate.h | 23 | ||||
-rw-r--r-- | src/libstate/policy.cpp | 4 |
3 files changed, 25 insertions, 19 deletions
diff --git a/src/libstate/libstate.cpp b/src/libstate/libstate.cpp index 919b12494..2e75453e9 100644 --- a/src/libstate/libstate.cpp +++ b/src/libstate/libstate.cpp @@ -1,6 +1,6 @@ /* * Library Internal/Global State -* (C) 1999-2008 Jack Lloyd +* (C) 1999-2010 Jack Lloyd * * Distributed under the terms of the Botan license */ @@ -119,13 +119,9 @@ Allocator* Library_State::get_allocator(const std::string& type) const if(!cached_default_allocator) { - std::string chosen = this->option("base/default_allocator"); - - if(chosen == "") - chosen = "malloc"; - cached_default_allocator = - search_map<std::string, Allocator*>(alloc_factory, chosen, 0); + search_map<std::string, Allocator*>(alloc_factory, + default_allocator_name, 0); } return cached_default_allocator; @@ -154,7 +150,7 @@ void Library_State::set_default_allocator(const std::string& type) if(type == "") return; - this->set("conf", "base/default_allocator", type); + default_allocator_name = type; cached_default_allocator = 0; } @@ -237,7 +233,7 @@ std::string Library_State::option(const std::string& key) const /** Return a reference to the Algorithm_Factory */ -Algorithm_Factory& Library_State::algorithm_factory() +Algorithm_Factory& Library_State::algorithm_factory() const { if(!m_algorithm_factory) throw Invalid_State("Uninitialized in Library_State::algorithm_factory"); @@ -273,6 +269,7 @@ void Library_State::initialize(bool thread_safe) config_lock = mutex_factory->make(); cached_default_allocator = 0; + default_allocator_name = "locking"; add_allocator(new Malloc_Allocator); add_allocator(new Locking_Allocator(mutex_factory->make())); @@ -281,8 +278,6 @@ void Library_State::initialize(bool thread_safe) add_allocator(new MemoryMapping_Allocator(mutex_factory->make())); #endif - set_default_allocator("locking"); - load_default_config(); std::vector<Engine*> engines; diff --git a/src/libstate/libstate.h b/src/libstate/libstate.h index d5c442214..d8d56bfd3 100644 --- a/src/libstate/libstate.h +++ b/src/libstate/libstate.h @@ -34,7 +34,7 @@ class BOTAN_DLL Library_State /** * @return the global Algorithm_Factory */ - Algorithm_Factory& algorithm_factory(); + Algorithm_Factory& algorithm_factory() const; /** * @param name the name of the allocator @@ -133,6 +133,7 @@ class BOTAN_DLL Library_State Mutex* config_lock; Mutex* allocator_lock; + std::string default_allocator_name; std::map<std::string, Allocator*> alloc_factory; mutable Allocator* cached_default_allocator; std::vector<Allocator*> allocators; @@ -140,12 +141,24 @@ class BOTAN_DLL Library_State Algorithm_Factory* m_algorithm_factory; }; -/* -* Global State +/** +* Access the global library state +* @return reference to the global library state */ BOTAN_DLL Library_State& global_state(); -BOTAN_DLL void set_global_state(Library_State*); -BOTAN_DLL Library_State* swap_global_state(Library_State*); + +/** +* Set the global state object +* @param state the new global state to use +*/ +BOTAN_DLL void set_global_state(Library_State* state); + +/** +* Swap the current state for another +* @param new_state the new state object to use +* @return the previous state (or NULL if none) +*/ +BOTAN_DLL Library_State* swap_global_state(Library_State* new_state); } diff --git a/src/libstate/policy.cpp b/src/libstate/policy.cpp index d792443a0..7202f8df6 100644 --- a/src/libstate/policy.cpp +++ b/src/libstate/policy.cpp @@ -1,6 +1,6 @@ /* * Default Policy -* (C) 1999-2008 Jack Lloyd +* (C) 1999-2010 Jack Lloyd * * Distributed under the terms of the Botan license */ @@ -284,8 +284,6 @@ void set_default_aliases(Library_State& config) */ void set_default_config(Library_State& config) { - config.set_option("base/default_allocator", "malloc"); - config.set_option("x509/exts/basic_constraints", "critical"); config.set_option("x509/exts/subject_key_id", "yes"); config.set_option("x509/exts/authority_key_id", "yes"); |