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/thread.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib/thread.c') diff --git a/lib/thread.c b/lib/thread.c index 8324783a7b..87ad3d8823 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -724,9 +724,7 @@ void thread_master_free(struct thread_master *m) list_delete(&m->cancel_req); m->cancel_req = NULL; - hash_clean(m->cpu_record, cpu_record_hash_free); - hash_free(m->cpu_record); - m->cpu_record = NULL; + hash_clean_and_free(&m->cpu_record, cpu_record_hash_free); XFREE(MTYPE_THREAD_MASTER, m->name); XFREE(MTYPE_THREAD_MASTER, m->handler.pfds); -- cgit v1.2.3