blob: 6155b3bd27b8954e68b17101194f34c601d8230a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
/*
* Library initialization
* (C) 1999-2009.2015 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
#include <botan/init.h>
#include <botan/libstate.h>
#include <botan/global_state.h>
namespace Botan {
LibraryInitializer::LibraryInitializer()
{
/*
This two stage initialization process is because Library_State's
constructor will implicitly refer to global state through the
allocators and so forth, so global_state() has to be a valid
reference before initialize() can be called. Yeah, gross.
*/
m_owned = Global_State_Management::set_global_state_unless_set(new Library_State);
if(m_owned)
{
try
{
global_state().initialize();
}
catch(...)
{
Global_State_Management::set_global_state(nullptr);
throw;
}
}
}
LibraryInitializer::~LibraryInitializer()
{
if(m_owned)
Global_State_Management::set_global_state(nullptr);
}
}
|