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 /bgpd/bgp_nexthop.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 'bgpd/bgp_nexthop.c')
-rw-r--r-- | bgpd/bgp_nexthop.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index 00a0bc840..f1f6b031a 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -166,11 +166,7 @@ void bgp_tip_hash_init(struct bgp *bgp) void bgp_tip_hash_destroy(struct bgp *bgp) { - if (bgp->tip_hash == NULL) - return; - hash_clean(bgp->tip_hash, bgp_tip_hash_free); - hash_free(bgp->tip_hash); - bgp->tip_hash = NULL; + hash_clean_and_free(&bgp->tip_hash, bgp_tip_hash_free); } /* Add/Update Tunnel-IP entry of bgp martian next-hop table. @@ -305,11 +301,7 @@ void bgp_address_init(struct bgp *bgp) void bgp_address_destroy(struct bgp *bgp) { - if (bgp->address_hash == NULL) - return; - hash_clean(bgp->address_hash, bgp_address_hash_free); - hash_free(bgp->address_hash); - bgp->address_hash = NULL; + hash_clean_and_free(&bgp->address_hash, bgp_address_hash_free); } static void bgp_address_add(struct bgp *bgp, struct connected *ifc, |