aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-06-25 12:04:55 +0000
committerlloyd <[email protected]>2006-06-25 12:04:55 +0000
commiteae468a0bbbc0477510a64e0eb19a872b0aaefac (patch)
treebb715166d14332421c8300837b832b0a520776a7
parentec83a0349f62f98765b93b3191c2b70e2aab5939 (diff)
Add a set_timer method to Library_State, and rearrange the order
of initialization in the constructor.
-rw-r--r--include/libstate.h1
-rw-r--r--src/libstate.cpp21
2 files changed, 15 insertions, 7 deletions
diff --git a/include/libstate.h b/include/libstate.h
index d242e5967..f699c9330 100644
--- a/include/libstate.h
+++ b/include/libstate.h
@@ -40,6 +40,7 @@ class Library_State
void add_entropy(EntropySource&, bool);
u32bit seed_prng(bool, u32bit);
+ void set_timer(Timer*);
u64bit system_clock() const;
void set_option(const std::string&, const std::string&,
diff --git a/src/libstate.cpp b/src/libstate.cpp
index 98ccb5e7c..a2a3bbe9a 100644
--- a/src/libstate.cpp
+++ b/src/libstate.cpp
@@ -127,6 +127,15 @@ void Library_State::add_allocator(Allocator* allocator)
}
/*************************************************
+* Set the high resolution clock implementation *
+*************************************************/
+void Library_State::set_timer(Timer* new_timer)
+ {
+ delete timer;
+ timer = new_timer;
+ }
+
+/*************************************************
* Read a high resolution clock *
*************************************************/
u64bit Library_State::system_clock() const
@@ -319,15 +328,13 @@ X509_GlobalState& Library_State::x509_state()
/*************************************************
* Library_State Constructor *
*************************************************/
-Library_State::Library_State(Mutex_Factory* mutex_factory, Timer* timer)
+Library_State::Library_State(Mutex_Factory* mutex_factory)
{
if(!mutex_factory)
mutex_factory = new Mutex_Factory;
- if(!timer)
- timer = new Timer;
this->mutex_factory = mutex_factory;
- this->timer = timer;
+ this->timer = new Timer();
this->transcoder = 0;
locks["settings"] = get_mutex();
@@ -352,6 +359,7 @@ Library_State::~Library_State()
delete entropy_sources[j];
delete rng;
+ delete timer;
for(u32bit j = 0; j != engines.size(); ++j)
delete engines[j];
@@ -364,12 +372,11 @@ Library_State::~Library_State()
delete j->second;
}
- delete mutex_factory;
- delete timer;
-
for(std::map<std::string, Mutex*>::iterator j = locks.begin();
j != locks.end(); ++j)
delete j->second;
+
+ delete mutex_factory;
}
}