The unified diff between revisions [77e3623e..] and [395d2422..] is displayed below. It can also be downloaded as a raw diff.

#
#
# patch "include/libstate.h"
#  from [22a10b0321c1a4facc15ccdfec09b701e220b0cb]
#    to [4dddb269a906154b79debb9588397ac08334ccf6]
#
# patch "src/init_def.cpp"
#  from [eeea722a966e382b9b30c4b44c3a55eb0acd0b10]
#    to [032c0a1f7bd132c86506da3f4756a1f39a49e6aa]
#
# patch "src/libstate.cpp"
#  from [c26fe461401e2f9a86a5a6a04dd382258fda744c]
#    to [233c9231a05eae79ae231f8136850b43c34914d3]
#
============================================================
--- include/libstate.h	22a10b0321c1a4facc15ccdfec09b701e220b0cb
+++ include/libstate.h	4dddb269a906154b79debb9588397ac08334ccf6
@@ -22,6 +22,15 @@ class Library_State
 class Library_State
    {
    public:
+      Library_State();
+      ~Library_State();
+
+      void initialize(const InitializerOptions&, Modules&);
+
+      void load(Modules&);
+
+      void add_engine(class Engine*);
+
       class Engine_Iterator
          {
          public:
@@ -58,8 +67,6 @@ class Library_State

       class Config& config() const;

-      void add_engine(class Engine*);
-
       class Mutex* get_mutex() const;
       class Mutex* get_named_mutex(const std::string&);

@@ -72,9 +79,6 @@ class Library_State
       void set_transcoder(class Charset_Transcoder*);
       std::string transcode(const std::string,
                             Character_Set, Character_Set) const;
-
-      Library_State(const InitializerOptions&, Modules&);
-      ~Library_State();
    private:
       Library_State(const Library_State&) {}
       Library_State& operator=(const Library_State&) { return (*this); }
============================================================
--- src/init_def.cpp	eeea722a966e382b9b30c4b44c3a55eb0acd0b10
+++ src/init_def.cpp	032c0a1f7bd132c86506da3f4756a1f39a49e6aa
@@ -18,8 +18,10 @@ void LibraryInitializer::initialize(cons
    {
    try
       {
-      set_global_state(new Library_State(args, modules));
+      set_global_state(new Library_State);

+      global_state().initialize(args, modules);
+
       if(args.fips_mode() || args.self_test())
          {
          if(!FIPS140::passes_self_tests())
============================================================
--- src/libstate.cpp	c26fe461401e2f9a86a5a6a04dd382258fda744c
+++ src/libstate.cpp	233c9231a05eae79ae231f8136850b43c34914d3
@@ -311,7 +311,6 @@ Config& Library_State::config() const
    {
    if(!config_obj)
       {
-      printf("Lazy creation of the global config\n");
       config_obj = new Config();
       config_obj->load_defaults();
       }
@@ -320,16 +319,23 @@ Config& Library_State::config() const
    }

 /*************************************************
-* Library_State Constructor                      *
+* Load a set of modules                          *
 *************************************************/
-Library_State::Library_State(const InitializerOptions& args,
-                             Modules& modules)
+void Library_State::initialize(const InitializerOptions& args,
+                               Modules& modules)
    {
+   if(mutex_factory)
+      throw Invalid_State("Library_State has already been initialized");
+
    if(args.thread_safe())
       mutex_factory = modules.mutex_factory();
    else
       mutex_factory = new Default_Mutex_Factory;

+   cached_default_allocator = 0;
+   x509_state_obj = 0;
+   ui = 0;
+
    timer = modules.timer();
    transcoder = modules.transcoder();

@@ -340,10 +346,6 @@ Library_State::Library_State(const Initi
    locks["allocator"] = get_mutex();
    locks["rng"] = get_mutex();
    locks["engine"] = get_mutex();
-   rng = 0;
-   cached_default_allocator = 0;
-   x509_state_obj = 0;
-   ui = 0;

    std::vector<Allocator*> mod_allocs = modules.allocators();
    for(u32bit j = 0; j != mod_allocs.size(); ++j)
@@ -379,6 +381,24 @@ Library_State::Library_State(const Initi
    }

 /*************************************************
+* Library_State Constructor                      *
+*************************************************/
+Library_State::Library_State()
+   {
+   mutex_factory = 0;
+
+   timer = 0;
+   config_obj = 0;
+   x509_state_obj = 0;
+
+   ui = 0;
+   transcoder = 0;
+   rng = 0;
+   cached_default_allocator = 0;
+   ui = 0;
+   }
+
+/*************************************************
 * Library_State Destructor                       *
 *************************************************/
 Library_State::~Library_State()