Botan 1.10.17
Botan::Global_State_Management Namespace Reference

Functions

Library_Stateglobal_state ()
bool global_state_exists ()
void set_global_state (Library_State *new_state)
bool set_global_state_unless_set (Library_State *new_state)
Library_Stateswap_global_state (Library_State *new_state)

Detailed Description

Namespace for management of the global state

Function Documentation

◆ global_state()

BOTAN_DLL Library_State & Botan::Global_State_Management::global_state ( )

Access the global library state

Returns
reference to the global library state

Definition at line 32 of file global_state.cpp.

33 {
34 /* Lazy initialization. Botan still needs to be deinitialized later
35 on or memory might leak.
36 */
37 if(!global_lib_state)
38 {
39 global_lib_state = new Library_State;
40 global_lib_state->initialize(true);
41 }
42
43 return (*global_lib_state);
44 }
void initialize(bool thread_safe)
Definition libstate.cpp:197

References global_state(), and Botan::Library_State::initialize().

Referenced by global_state().

◆ global_state_exists()

BOTAN_DLL bool Botan::Global_State_Management::global_state_exists ( )

Query if the library is currently initialized

Returns
true iff the library is initialized

Definition at line 84 of file global_state.cpp.

85 {
86 return (global_lib_state != 0);
87 }

References global_state_exists().

Referenced by global_state_exists().

◆ set_global_state()

BOTAN_DLL void Botan::Global_State_Management::set_global_state ( Library_State * state)

Set the global state object

Parameters
statethe new global state to use

Definition at line 49 of file global_state.cpp.

50 {
51 delete swap_global_state(new_state);
52 }
Library_State * swap_global_state(Library_State *new_state)

References set_global_state(), and swap_global_state().

Referenced by Botan::LibraryInitializer::deinitialize(), Botan::LibraryInitializer::initialize(), and set_global_state().

◆ set_global_state_unless_set()

BOTAN_DLL bool Botan::Global_State_Management::set_global_state_unless_set ( Library_State * state)

Set the global state object unless it is already set

Parameters
statethe new global state to use
Returns
true if the state parameter is now being used as the global state, or false if one was already set, in which case the parameter was deleted immediately

Definition at line 57 of file global_state.cpp.

58 {
59 if(global_lib_state)
60 {
61 delete new_state;
62 return false;
63 }
64 else
65 {
66 delete swap_global_state(new_state);
67 return true;
68 }
69 }

References set_global_state_unless_set(), and swap_global_state().

Referenced by set_global_state_unless_set().

◆ swap_global_state()

BOTAN_DLL Library_State * Botan::Global_State_Management::swap_global_state ( Library_State * new_state)

Swap the current state for another

Parameters
new_statethe new state object to use
Returns
previous state (or NULL if none)

Definition at line 74 of file global_state.cpp.

75 {
76 Library_State* old_state = global_lib_state;
77 global_lib_state = new_state;
78 return old_state;
79 }

References swap_global_state().

Referenced by set_global_state(), set_global_state_unless_set(), and swap_global_state().