refactor: smart pointer usage

Signed-off-by: Federico Aponte <federico.aponte@sysdig.com>
This commit is contained in:
Federico Aponte
2024-05-05 23:47:47 +02:00
committed by poiana
parent 96c47e5eeb
commit 62d1c4fc4d
13 changed files with 52 additions and 78 deletions

View File

@@ -44,7 +44,7 @@ void stats_manager::format(
out += "Rule counts by severity:\n";
for (size_t i = 0; i < m_by_priority.size(); i++)
{
auto val = m_by_priority[i].get()->load();
auto val = m_by_priority[i]->load();
if (val > 0)
{
falco_common::format_priority(
@@ -56,7 +56,7 @@ void stats_manager::format(
out += "Triggered rules by rule name:\n";
for (size_t i = 0; i < m_by_rule_id.size(); i++)
{
auto val = m_by_rule_id[i].get()->load();
auto val = m_by_rule_id[i]->load();
if (val > 0)
{
out += " " + rules.at(i)->name + ": " + std::to_string(val) + "\n";
@@ -68,13 +68,11 @@ void stats_manager::on_rule_loaded(const falco_rule& rule)
{
while (m_by_rule_id.size() <= rule.id)
{
m_by_rule_id.emplace_back();
m_by_rule_id[m_by_rule_id.size() - 1].reset(new std::atomic<uint64_t>(0));
m_by_rule_id.emplace_back(std::make_unique<std::atomic<uint64_t>>(0));
}
while (m_by_priority.size() <= (size_t) rule.priority)
{
m_by_priority.emplace_back();
m_by_priority[m_by_priority.size() - 1].reset(new std::atomic<uint64_t>(0));
m_by_priority.emplace_back(std::make_unique<std::atomic<uint64_t>>(0));
}
}