From d8bc11a592110abdd14d11dfcb2ce623653ecab5 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 21 Mar 2023 08:54:21 -0400 Subject: *: 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 --- lib/frrscript.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib/frrscript.c') diff --git a/lib/frrscript.c b/lib/frrscript.c index 4248a45002..1b99c7e2c6 100644 --- a/lib/frrscript.c +++ b/lib/frrscript.c @@ -398,8 +398,7 @@ fail: void frrscript_delete(struct frrscript *fs) { - hash_clean(fs->lua_function_hash, lua_function_free); - hash_free(fs->lua_function_hash); + hash_clean_and_free(&fs->lua_function_hash, lua_function_free); XFREE(MTYPE_SCRIPT, fs->name); XFREE(MTYPE_SCRIPT, fs); } @@ -417,8 +416,7 @@ void frrscript_init(const char *sd) void frrscript_fini(void) { - hash_clean(codec_hash, codec_free); - hash_free(codec_hash); + hash_clean_and_free(&codec_hash, codec_free); frrscript_names_destroy(); } -- cgit v1.2.3