From eae468a0bbbc0477510a64e0eb19a872b0aaefac Mon Sep 17 00:00:00 2001 From: lloyd Date: Sun, 25 Jun 2006 12:04:55 +0000 Subject: Add a set_timer method to Library_State, and rearrange the order of initialization in the constructor. --- src/libstate.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/libstate.cpp') diff --git a/src/libstate.cpp b/src/libstate.cpp index 98ccb5e7c..a2a3bbe9a 100644 --- a/src/libstate.cpp +++ b/src/libstate.cpp @@ -126,6 +126,15 @@ void Library_State::add_allocator(Allocator* allocator) alloc_factory[type] = 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 * *************************************************/ @@ -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::iterator j = locks.begin(); j != locks.end(); ++j) delete j->second; + + delete mutex_factory; } } -- cgit v1.2.3