diff options
| author | Donald Sharp <sharpd@nvidia.com> | 2023-03-21 08:54:21 -0400 |
|---|---|---|
| committer | Donald Sharp <sharpd@nvidia.com> | 2023-03-21 08:54:21 -0400 |
| commit | d8bc11a592110abdd14d11dfcb2ce623653ecab5 (patch) | |
| tree | eee3628586497e48192f65326316f0eb91114011 /lib/distribute.c | |
| parent | 2e1ea892220dccb8a4c72e438cb3bbd4cac22b2b (diff) | |
*: 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 'lib/distribute.c')
| -rw-r--r-- | lib/distribute.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/distribute.c b/lib/distribute.c index 4cfdcc7840..65487676d6 100644 --- a/lib/distribute.c +++ b/lib/distribute.c @@ -445,14 +445,15 @@ int config_write_distribute(struct vty *vty, void distribute_list_delete(struct distribute_ctx **ctx) { - if ((*ctx)->disthash) { - hash_clean((*ctx)->disthash, (void (*)(void *))distribute_free); + hash_clean_and_free(&(*ctx)->disthash, + (void (*)(void *))distribute_free); + + if (dist_ctx_list) { + listnode_delete(dist_ctx_list, *ctx); + if (list_isempty(dist_ctx_list)) + list_delete(&dist_ctx_list); } - if (!dist_ctx_list) - dist_ctx_list = list_new(); - listnode_delete(dist_ctx_list, *ctx); - if (list_isempty(dist_ctx_list)) - list_delete(&dist_ctx_list); + XFREE(MTYPE_DISTRIBUTE_CTX, (*ctx)); } |
