From 8766fceefca9b6763a3a0e276959af86c50a9827 Mon Sep 17 00:00:00 2001 From: Louis Scalbert Date: Thu, 27 Apr 2023 15:11:42 +0200 Subject: [PATCH] lib: move flex_algo_delete() just after flex_algo_alloc() Move flex_algo_delete() just after flex_algo_alloc(). No change on code. Signed-off-by: Louis Scalbert --- lib/flex_algo.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/flex_algo.c b/lib/flex_algo.c index 4ad4c233ae..612bfbc8cf 100644 --- a/lib/flex_algo.c +++ b/lib/flex_algo.c @@ -48,6 +48,25 @@ struct flex_algo *flex_algo_alloc(struct flex_algos *flex_algos, return fa; } +void flex_algo_delete(struct flex_algos *flex_algos, uint8_t algorithm) +{ + struct listnode *node, *nnode; + struct flex_algo *fa; + + for (ALL_LIST_ELEMENTS(flex_algos->flex_algos, node, nnode, fa)) { + if (fa->algorithm != algorithm) + continue; + if (flex_algos->releaser) + flex_algos->releaser(fa->data); + admin_group_term(&fa->admin_group_exclude_any); + admin_group_term(&fa->admin_group_include_any); + admin_group_term(&fa->admin_group_include_all); + listnode_delete(flex_algos->flex_algos, fa); + XFREE(MTYPE_FLEX_ALGO, fa); + return; + } +} + /** * @brief Look up the local flex-algo object by its algorithm number. * @param algorithm flex-algo algorithm number @@ -94,25 +113,6 @@ bool flex_algo_definition_cmp(struct flex_algo *fa1, struct flex_algo *fa2) return true; } -void flex_algo_delete(struct flex_algos *flex_algos, uint8_t algorithm) -{ - struct listnode *node, *nnode; - struct flex_algo *fa; - - for (ALL_LIST_ELEMENTS(flex_algos->flex_algos, node, nnode, fa)) { - if (fa->algorithm != algorithm) - continue; - if (flex_algos->releaser) - flex_algos->releaser(fa->data); - admin_group_term(&fa->admin_group_exclude_any); - admin_group_term(&fa->admin_group_include_any); - admin_group_term(&fa->admin_group_include_all); - listnode_delete(flex_algos->flex_algos, fa); - XFREE(MTYPE_FLEX_ALGO, fa); - return; - } -} - /** * Check SR Algorithm is Flex-Algo * according to RFC9350 section 4