From df7ad871993354fc7d42401c29ae4d6097d6cec8 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Fri, 4 Oct 2019 02:19:18 +0100 Subject: [PATCH] encapsulate color_list --- color.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/color.c b/color.c index 817478555..d15b86fd0 100644 --- a/color.c +++ b/color.c @@ -219,6 +219,27 @@ static void quotes_clear(struct Colors *c) c->quotes_used = 0; } +/** + * color_list_free - Free the list of curses colours + * @param ptr Colours + */ +static void color_list_free(struct ColorList **ptr) +{ + if (!ptr || !*ptr) + return; + + struct ColorList *cl = *ptr; + struct ColorList *next = NULL; + + while (cl) + { + next = cl->next; + FREE(&cl); + cl = next; + } + *ptr = NULL; +} + /** * color_line_new - Create a new ColorLine * @retval ptr Newly allocated ColorLine @@ -278,6 +299,8 @@ static void colors_clear(struct Colors *c) { defs_clear(c); quotes_clear(c); + + color_list_free(&c->user_colors); } /** @@ -1283,15 +1306,6 @@ void mutt_colors_free(void) color_line_list_clear(&Colors->index_tag_list); color_line_list_clear(&Colors->status_list); - struct ColorList *cl = Colors->user_colors; - struct ColorList *next = NULL; - while (cl) - { - next = cl->next; - FREE(&cl); - cl = next; - } - Colors->user_colors = NULL; colors_clear(Colors); defs_free(Colors); quotes_free(Colors); -- 2.40.0