From 9df78e7c3ad777a3ef5c0fa84fec5ab151201c59 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 19 Oct 2016 11:09:57 -0400 Subject: [PATCH] lib: Add cleanup for routemaps Some new routemap hash data structures were not being properly cleaned up. Add the hash_free code in. This code does not fix the variety of daemons that don't actually call route_map_finish. Signed-off-by: Donald Sharp --- lib/routemap.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/lib/routemap.c b/lib/routemap.c index 7c30051bba..eec36d3717 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -1124,18 +1124,6 @@ route_map_event_hook (void (*func) (route_map_event_t, const char *)) route_map_master.event_hook = func; } -void -route_map_finish (void) -{ - vector_free (route_match_vec); - route_match_vec = NULL; - vector_free (route_set_vec); - route_set_vec = NULL; - /* cleanup route_map */ - while (route_map_master.head) - route_map_delete (route_map_master.head); -} - /* Routines for route map dependency lists and dependency processing */ static int route_map_rmap_hash_cmp (const void *p1, const void *p2) @@ -1838,6 +1826,26 @@ route_map_rule_tag_free (void *rule) XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); } +void +route_map_finish (void) +{ + int i; + + vector_free (route_match_vec); + route_match_vec = NULL; + vector_free (route_set_vec); + route_set_vec = NULL; + + /* cleanup route_map */ + while (route_map_master.head) + route_map_delete (route_map_master.head); + + for (i = 1; i < ROUTE_MAP_DEP_MAX; i++) + hash_free(route_map_dep_hash[i]); + + hash_free (route_map_master_hash); +} + /* Initialization of route map vector. */ void route_map_init (void) -- 2.39.5