zwoop commented on code in PR #12304: URL: https://github.com/apache/trafficserver/pull/12304#discussion_r2162170838
########## plugins/header_rewrite/header_rewrite.cc: ########## @@ -115,28 +115,24 @@ class RulesConfig bool parse_config(const std::string &fname, TSHttpHookID default_hook, char *from_url = nullptr, char *to_url = nullptr); private: - bool add_rule(RuleSet *rule); + void add_rule(std::unique_ptr<RuleSet> rule); TSCont _cont; RuleSet *_rules[TS_HTTP_LAST_HOOK + 1]; ResourceIDs _resids[TS_HTTP_LAST_HOOK + 1]; }; -// Helper function to add a rule to the rulesets -bool -RulesConfig::add_rule(RuleSet *rule) +void +RulesConfig::add_rule(std::unique_ptr<RuleSet> rule) { - if (rule && rule->has_operator()) { - Dbg(dbg_ctl, " Adding rule to hook=%s", TSHttpHookNameLookup(rule->get_hook())); - if (nullptr == _rules[rule->get_hook()]) { - _rules[rule->get_hook()] = rule; - } else { - _rules[rule->get_hook()]->append(rule); - } - return true; - } + auto raw = rule.release(); - return false; + Dbg(pi_dbg_ctl, " Adding rule to hook=%s", TSHttpHookNameLookup(raw->get_hook())); + if (nullptr == _rules[raw->get_hook()]) { + _rules[raw->get_hook()] = raw; + } else { + _rules[raw->get_hook()]->append(raw); Review Comment: Changed to use std::unique_ptr consistently around the RuleSet -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@trafficserver.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org