-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathremoved_option_registry.cc
More file actions
75 lines (60 loc) · 1.59 KB
/
removed_option_registry.cc
File metadata and controls
75 lines (60 loc) · 1.59 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "removed_option_registry.h"
#include <mutex>
#include <new>
#include <vector>
static std::vector<Removed_startup_option> g_removed_startup_options;
static std::mutex g_removed_startup_options_lock;
bool init_removed_startup_option_registry()
{
return false;
}
void free_removed_startup_option_registry()
{
std::lock_guard<std::mutex> guard(g_removed_startup_options_lock);
g_removed_startup_options.clear();
g_removed_startup_options.shrink_to_fit();
}
bool register_removed_startup_option(const char *name,
const char *value,
const char *filename)
{
Removed_startup_option row;
row.option_name= name ? name : "";
row.option_value= value ? value : "";
if (filename && *filename)
{
row.source= "CONFIG";
row.config_file= filename;
}
else
{
row.source= "COMMAND_LINE";
row.config_file.clear();
}
row.handling= "IGNORED";
try
{
std::lock_guard<std::mutex> guard(g_removed_startup_options_lock);
g_removed_startup_options.push_back(row);
}
catch (const std::bad_alloc &)
{
return true;
}
return false;
}
size_t removed_startup_option_count()
{
std::lock_guard<std::mutex> guard(g_removed_startup_options_lock);
return g_removed_startup_options.size();
}
bool get_removed_startup_option_copy(size_t index, Removed_startup_option *out)
{
if (!out)
return true;
std::lock_guard<std::mutex> guard(g_removed_startup_options_lock);
if (index >= g_removed_startup_options.size())
return true;
*out= g_removed_startup_options[index];
return false;
}