From affe9e99831408960b8b6f8477506ed2874a05dd Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 5 Oct 2017 10:51:01 -0400 Subject: *: Convert list_delete(struct list *) to ** to allow nulling Convert the list_delete(struct list *) function to use struct list **. This is to allow the list pointer to be nulled. I keep running into uses of this list_delete function where we forget to set the returned pointer to NULL and attempt to use it and then experience a crash, usually after the developer has long since left the building. Let's make the api explicit in it setting the list pointer to null. Cynical Prediction: This code will expose a attempt to use the NULL'ed list pointer in some obscure bit of code. Signed-off-by: Donald Sharp --- lib/hash.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/hash.c') diff --git a/lib/hash.c b/lib/hash.c index 243521bef..d2846d737 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -318,8 +318,7 @@ void hash_free(struct hash *hash) if (_hashes) { listnode_delete(_hashes, hash); if (_hashes->count == 0) { - list_delete(_hashes); - _hashes = NULL; + list_delete_and_null(&_hashes); } } } -- cgit v1.2.3