X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fcolors.c;h=5a79fd9bbfff8b2c6a7967e499af18df19c98544;hb=bf5fc85f37af5698d477edc5dae250bf8984ed00;hp=1cf4c973cfc63c933b221b4384041764eb51beac;hpb=92cb9c45ac41c2e1f7a9517a66e239ee2cb8ccc4;p=ncmpc.git diff --git a/src/colors.c b/src/colors.c index 1cf4c97..5a79fd9 100644 --- a/src/colors.c +++ b/src/colors.c @@ -165,13 +165,13 @@ colors_str2color(const char *str) /* This function is called from conf.c before curses have been started, * it adds the definition to the color_definition_list and init_color() is * done in colors_start() */ -int +bool colors_define(const char *name, short r, short g, short b) { int color = colors_str2color(name); if (color < 0) - return color; + return false; color_definition_entry_t *entry = g_malloc(sizeof(color_definition_entry_t)); @@ -182,10 +182,10 @@ colors_define(const char *name, short r, short g, short b) color_definition_list = g_list_append(color_definition_list, entry); - return 0; + return true; } -int +bool colors_assign(const char *name, const char *value) { color_entry_t *entry = colors_lookup_by_name(name); @@ -193,15 +193,15 @@ colors_assign(const char *name, const char *value) if (!entry) { fprintf(stderr, "%s: %s", _("Unknown color field"), name); - return -1; + return false; } const int color = colors_str2color(value); if (color == COLOR_ERROR) - return -1; + return false; entry->color = color; - return 0; + return true; } void @@ -240,14 +240,7 @@ colors_start(void) /* free the color_definition_list */ if (color_definition_list) { - GList *list = color_definition_list; - - while (list) { - g_free(list->data); - list=list->next; - } - - g_list_free(color_definition_list); + g_list_free_full(color_definition_list, g_free); color_definition_list = NULL; } }