From 55db80c6970b8643b4777c3b5586531e2d2e7469 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Wed, 17 Feb 2021 11:07:45 -0800 Subject: fb,settings: return NULL from _free() methods and ignore NULL parameters as benign --- src/fb.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/fb.c') diff --git a/src/fb.c b/src/fb.c index 03a04ac..f24e4fe 100644 --- a/src/fb.c +++ b/src/fb.c @@ -239,22 +239,26 @@ void fb_get_put_pages_count(fb_t *fb, unsigned *count) /* free the fb and associated resources */ -void fb_free(fb_t *fb) +fb_t * fb_free(fb_t *fb) { - if (fb->active_page) - fb_release(fb); + if (fb) { + if (fb->active_page) + fb_release(fb); - /* TODO: free all the pages */ + /* TODO: free all the pages */ - if (fb->ops->shutdown && fb->ops_context) - fb->ops->shutdown(fb, fb->ops_context); + if (fb->ops->shutdown && fb->ops_context) + fb->ops->shutdown(fb, fb->ops_context); - pthread_mutex_destroy(&fb->ready_mutex); - pthread_cond_destroy(&fb->ready_cond); - pthread_mutex_destroy(&fb->inactive_mutex); - pthread_cond_destroy(&fb->inactive_cond); + pthread_mutex_destroy(&fb->ready_mutex); + pthread_cond_destroy(&fb->ready_cond); + pthread_mutex_destroy(&fb->inactive_mutex); + pthread_cond_destroy(&fb->inactive_cond); - free(fb); + free(fb); + } + + return NULL; } -- cgit v1.2.3