aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/module/GlobalRegisterTable.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2023-12-16 05:12:25 +0000
committersaturneric <[email protected]>2023-12-16 05:12:25 +0000
commitc41074792f8c3b966b6d637c9e9b0ee10c5255e7 (patch)
treea20f44b3f275f69d0185a0dcf926082721db3220 /src/core/module/GlobalRegisterTable.cpp
parentfix: slove threading and memory issues (diff)
downloadGpgFrontend-c41074792f8c3b966b6d637c9e9b0ee10c5255e7.tar.gz
GpgFrontend-c41074792f8c3b966b6d637c9e9b0ee10c5255e7.zip
fix: clean up envirnoment when app exits
Diffstat (limited to 'src/core/module/GlobalRegisterTable.cpp')
-rw-r--r--src/core/module/GlobalRegisterTable.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/core/module/GlobalRegisterTable.cpp b/src/core/module/GlobalRegisterTable.cpp
index 6f43aeb4..eda6c744 100644
--- a/src/core/module/GlobalRegisterTable.cpp
+++ b/src/core/module/GlobalRegisterTable.cpp
@@ -45,7 +45,7 @@ class GlobalRegisterTable::Impl {
public:
struct RTNode {
std::optional<std::any> value = std::nullopt;
- std::unordered_map<std::string, std::unique_ptr<RTNode>> children;
+ std::unordered_map<std::string, SecureUniquePtr<RTNode>> children;
int version = 0;
const std::type_info* type = nullptr;
};
@@ -61,12 +61,13 @@ class GlobalRegisterTable::Impl {
{
std::unique_lock lock(lock_);
auto& root_rt_node =
- global_register_table_.emplace(n, std::make_unique<RTNode>())
+ global_register_table_.emplace(n, SecureCreateUniqueObject<RTNode>())
.first->second;
RTNode* current = root_rt_node.get();
while (std::getline(iss, segment, '.')) {
- current = current->children.emplace(segment, std::make_unique<RTNode>())
+ current = current->children
+ .emplace(segment, SecureCreateUniqueObject<RTNode>())
.first->second.get();
}
@@ -137,7 +138,7 @@ class GlobalRegisterTable::Impl {
}
private:
- using Table = std::map<Namespace, std::unique_ptr<RTNode>>;
+ using Table = std::map<Namespace, SecureUniquePtr<RTNode>>;
std::shared_mutex lock_;
GlobalRegisterTable* parent_;