bgpd: Add ability to clean lcommunity hash

Ensure that we don't leak any memory on shutdown.
Since the bgp_lcommunity.c file mirrors bgp_ecommunity.c
Add the same code for shutdown that ecommunity has.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2017-01-25 08:26:21 -05:00
parent 52951b630a
commit 47350fd9f4

View File

@ -54,6 +54,12 @@ lcommunity_free (struct lcommunity **lcom)
lcom = NULL; lcom = NULL;
} }
static void
lcommunity_hash_free (struct lcommunity *lcom)
{
lcommunity_free (&lcom);
}
/* Add a new Large Communities value to Large Communities /* Add a new Large Communities value to Large Communities
Attribute structure. When the value is already exists in the Attribute structure. When the value is already exists in the
structure, we don't add the value. Newly added value is sorted by structure, we don't add the value. Newly added value is sorted by
@ -287,6 +293,7 @@ lcommunity_init (void)
void void
lcommunity_finish (void) lcommunity_finish (void)
{ {
hash_clean (lcomhash, (void (*)(void *))lcommunity_hash_free);
hash_free (lcomhash); hash_free (lcomhash);
lcomhash = NULL; lcomhash = NULL;
} }