diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2021-02-17 11:07:45 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2021-02-17 11:07:45 -0800 |
commit | 55db80c6970b8643b4777c3b5586531e2d2e7469 (patch) | |
tree | ab4178a33ebc1c8d77ec6669a6c0d433574257c8 /src/fb.c | |
parent | 9e56788affedd6b01df6764732a4ba786f7a47f3 (diff) |
fb,settings: return NULL from _free() methods
and ignore NULL parameters as benign
Diffstat (limited to 'src/fb.c')
-rw-r--r-- | src/fb.c | 26 |
1 files changed, 15 insertions, 11 deletions
@@ -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; } |