summaryrefslogtreecommitdiff
path: root/lib/link_state.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2023-03-30 15:48:53 -0400
committerDonald Sharp <sharpd@nvidia.com>2023-04-06 18:00:09 -0400
commitb589466918337c11021fd4085aacf0d7e963a9a4 (patch)
tree9a56c43152d2733b5a1674152ac8d2c70e6dc891 /lib/link_state.c
parentcf35e49354699fb920997ba2448ea2088acb6a30 (diff)
*: Use a `struct prefix *p` instead of a `struct prefix` in functions
When passing a prefix into a function let's pass by address instead of pass by value. Let's save our stack space. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'lib/link_state.c')
-rw-r--r--lib/link_state.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/link_state.c b/lib/link_state.c
index 589c0ae704..0aba021b1a 100644
--- a/lib/link_state.c
+++ b/lib/link_state.c
@@ -333,7 +333,7 @@ int ls_attributes_same(struct ls_attributes *l1, struct ls_attributes *l2)
/**
* Link State prefix management functions
*/
-struct ls_prefix *ls_prefix_new(struct ls_node_id adv, struct prefix p)
+struct ls_prefix *ls_prefix_new(struct ls_node_id adv, struct prefix *p)
{
struct ls_prefix *new;
@@ -342,7 +342,7 @@ struct ls_prefix *ls_prefix_new(struct ls_node_id adv, struct prefix p)
new = XCALLOC(MTYPE_LS_DB, sizeof(struct ls_prefix));
new->adv = adv;
- new->pref = p;
+ new->pref = *p;
return new;
}
@@ -889,7 +889,7 @@ struct ls_subnet *ls_subnet_update(struct ls_ted *ted, struct ls_prefix *pref)
if (pref == NULL)
return NULL;
- old = ls_find_subnet(ted, pref->pref);
+ old = ls_find_subnet(ted, &pref->pref);
if (old) {
if (!ls_prefix_same(old->ls_pref, pref)) {
ls_prefix_del(old->ls_pref);
@@ -942,11 +942,12 @@ void ls_subnet_del_all(struct ls_ted *ted, struct ls_subnet *subnet)
ls_subnet_del(ted, subnet);
}
-struct ls_subnet *ls_find_subnet(struct ls_ted *ted, const struct prefix prefix)
+struct ls_subnet *ls_find_subnet(struct ls_ted *ted,
+ const struct prefix *prefix)
{
struct ls_subnet subnet = {};
- subnet.key = prefix;
+ subnet.key = *prefix;
return subnets_find(&ted->subnets, &subnet);
}
@@ -1846,7 +1847,7 @@ struct ls_subnet *ls_msg2subnet(struct ls_ted *ted, struct ls_message *msg,
subnet->status = UPDATE;
break;
case LS_MSG_EVENT_DELETE:
- subnet = ls_find_subnet(ted, pref->pref);
+ subnet = ls_find_subnet(ted, &pref->pref);
if (subnet) {
if (delete)
ls_subnet_del_all(ted, subnet);