Skip to content

Commit

Permalink
reduce alloc/free churn for port ifAlias strings
Browse files Browse the repository at this point in the history
  • Loading branch information
sflow committed May 26, 2023
1 parent ddb05f2 commit 7c0271a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Linux/mod_sonic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,8 @@ extern "C" {
// This "index" field is neither ifIndex nor osIndex, so ignore it.
if(my_strequal(c_name->str, HSP_SONIC_FIELD_IFSPEED))
prt->ifSpeed = db_getU64(c_val) * HSP_SONIC_FIELD_IFSPEED_UNITS;
if(my_strequal(c_name->str, HSP_SONIC_FIELD_IFALIAS)) {
if(my_strequal(c_name->str, HSP_SONIC_FIELD_IFALIAS)
&& !my_strequal(prt->ifAlias, c_val->str)) {
if(prt->ifAlias)
my_free(prt->ifAlias);
prt->ifAlias = my_strdup(c_val->str);
Expand Down

0 comments on commit 7c0271a

Please sign in to comment.