Github user SolidWallOfCode commented on a diff in the pull request:
https://github.com/apache/trafficserver/pull/229#discussion_r33062665
--- Diff: proxy/logging/LogField.cc ---
@@ -212,6 +269,51 @@ LogField::~LogField()
ats_free(m_symbol);
}
+TransactionMilestones::Milestone
+LogField::milestone_from_m_name(const char *m_name)
+{
+ milestone_map::iterator it;
+ TransactionMilestones::Milestone result =
TransactionMilestones::LAST_ENTRY;
+
+ it = m_milestone_map.find(m_name);
+ if (it != m_milestone_map.end())
+ result = it->second;
+
+ return result;
+}
+
+int
+LogField::milestones_from_m_name(const char *m_name,
TransactionMilestones::Milestone *ms1, TransactionMilestones::Milestone *ms2)
+{
+ milestone_map::iterator it;
+ char *ms_name;
+ size_t ms_name_len, skip;
+
+ ms_name_len = strcspn(m_name, " -");
+ ms_name = strndup(m_name, ms_name_len);
--- End diff --
It's very frowned upon to do allocations in the main path. The find method
should be changed to accept a `char const*` and length and avoid the
duplication / allocation here.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---