Skip to content

Commit

Permalink
refactor: shared_ptr construction
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Aponte <federico.aponte@sysdig.com>
  • Loading branch information
federico-sysdig authored and poiana committed Feb 26, 2024
1 parent 557929a commit 59c14f4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
3 changes: 1 addition & 2 deletions userspace/engine/evttype_index_ruleset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ void evttype_index_ruleset::clear()
{
for (size_t i = 0; i < m_rulesets.size(); i++)
{
std::shared_ptr<ruleset_filters> r(new ruleset_filters());
m_rulesets[i] = r;
m_rulesets[i] = std::make_shared<ruleset_filters>();
}
m_filters.clear();
}
Expand Down
8 changes: 3 additions & 5 deletions userspace/engine/evttype_index_ruleset.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ class evttype_index_ruleset: public filter_ruleset
// that matched.
bool run(sinsp_evt *evt, falco_rule& match);

// Evaluate an event against the ruleset and return all the
// matching rules.
// Evaluate an event against the ruleset and return all the
// matching rules.
bool run(sinsp_evt *evt, std::vector<falco_rule>& matches);

libsinsp::events::set<ppm_sc_code> sc_codes();
Expand Down Expand Up @@ -164,9 +164,7 @@ class evttype_index_ruleset_factory: public filter_ruleset_factory

inline std::shared_ptr<filter_ruleset> new_ruleset() override
{
std::shared_ptr<filter_ruleset> ret(
new evttype_index_ruleset(m_filter_factory));
return ret;
return std::make_shared<evttype_index_ruleset>(m_filter_factory);
}

private:
Expand Down
5 changes: 2 additions & 3 deletions userspace/engine/falco_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,8 @@ std::size_t falco_engine::add_source(const std::string &source,
std::shared_ptr<sinsp_evt_formatter_factory> formatter_factory)
{
// evttype_index_ruleset is the default ruleset implementation
std::shared_ptr<filter_ruleset_factory> ruleset_factory(
new evttype_index_ruleset_factory(filter_factory));
size_t idx = add_source(source, filter_factory, formatter_factory, ruleset_factory);
size_t idx = add_source(source, filter_factory, formatter_factory,
std::make_shared<evttype_index_ruleset_factory>(filter_factory));

if(source == falco_common::syscall_source)
{
Expand Down
8 changes: 3 additions & 5 deletions userspace/falco/app/actions/init_falco_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,11 @@ void configure_output_format(falco::app::state& s)
void add_source_to_engine(falco::app::state& s, const std::string& src)
{
auto src_info = s.source_infos.at(src);
auto& filterchecks = *src_info->filterchecks.get();
auto& filterchecks = *src_info->filterchecks;
auto* inspector = src_info->inspector.get();

auto filter_factory = std::shared_ptr<sinsp_filter_factory>(
new sinsp_filter_factory(inspector, filterchecks));
auto formatter_factory = std::shared_ptr<sinsp_evt_formatter_factory>(
new sinsp_evt_formatter_factory(inspector, filterchecks));
auto filter_factory = std::make_shared<sinsp_filter_factory>(inspector, filterchecks);
auto formatter_factory = std::make_shared<sinsp_evt_formatter_factory>(inspector, filterchecks);

if(s.config->m_json_output)
{
Expand Down

0 comments on commit 59c14f4

Please sign in to comment.