diff options
author | Donald Sharp <sharpd@nvidia.com> | 2023-03-21 13:54:21 +0100 |
---|---|---|
committer | Donald Sharp <sharpd@nvidia.com> | 2023-03-21 13:54:21 +0100 |
commit | d8bc11a592110abdd14d11dfcb2ce623653ecab5 (patch) | |
tree | eee3628586497e48192f65326316f0eb91114011 /ospfd/ospf_asbr.c | |
parent | Merge pull request #12816 from gpnaveen/stc_rte_err_msg (diff) | |
download | frr-d8bc11a592110abdd14d11dfcb2ce623653ecab5.tar.xz frr-d8bc11a592110abdd14d11dfcb2ce623653ecab5.zip |
*: Add a hash_clean_and_free() function
Add a hash_clean_and_free() function as well as convert
the code to use it. This function also takes a double
pointer to the hash to set it NULL. Also it cleanly
does nothing if the pointer is NULL( as a bunch of
code tested for ).
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'ospfd/ospf_asbr.c')
-rw-r--r-- | ospfd/ospf_asbr.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/ospfd/ospf_asbr.c b/ospfd/ospf_asbr.c index 5b5367811..6eada0b1a 100644 --- a/ospfd/ospf_asbr.c +++ b/ospfd/ospf_asbr.c @@ -450,15 +450,12 @@ static void ospf_aggr_unlink_external_info(void *data) void ospf_external_aggregator_free(struct ospf_external_aggr_rt *aggr) { - if (OSPF_EXTERNAL_RT_COUNT(aggr)) - hash_clean(aggr->match_extnl_hash, - (void *)ospf_aggr_unlink_external_info); + hash_clean_and_free(&aggr->match_extnl_hash, + (void *)ospf_aggr_unlink_external_info); if (IS_DEBUG_OSPF(lsa, EXTNL_LSA_AGGR)) zlog_debug("%s: Release the aggregator Address(%pI4/%d)", __func__, &aggr->p.prefix, aggr->p.prefixlen); - hash_free(aggr->match_extnl_hash); - aggr->match_extnl_hash = NULL; XFREE(MTYPE_OSPF_EXTERNAL_RT_AGGR, aggr); } @@ -983,13 +980,9 @@ static void ospf_handle_external_aggr_update(struct ospf *ospf) aggr->action = OSPF_ROUTE_AGGR_NONE; ospf_external_aggr_delete(ospf, rn); - if (OSPF_EXTERNAL_RT_COUNT(aggr)) - hash_clean( - aggr->match_extnl_hash, - (void *)ospf_aggr_handle_external_info); - - hash_free(aggr->match_extnl_hash); - XFREE(MTYPE_OSPF_EXTERNAL_RT_AGGR, aggr); + hash_clean_and_free( + &aggr->match_extnl_hash, + (void *)ospf_aggr_handle_external_info); } else if (aggr->action == OSPF_ROUTE_AGGR_MODIFY) { |