]> granicus.if.org Git - neomutt/commitdiff
move mutt_color_free
authorRichard Russon <rich@flatcap.org>
Fri, 4 Oct 2019 01:21:59 +0000 (02:21 +0100)
committerRichard Russon <rich@flatcap.org>
Tue, 8 Oct 2019 22:45:06 +0000 (23:45 +0100)
color.c

diff --git a/color.c b/color.c
index d15b86fd098dc5f019ac5328a521f181d42adbd1..34440c329ccfba5646c1c625c8732c61258f4427 100644 (file)
--- a/color.c
+++ b/color.c
@@ -240,6 +240,52 @@ static void color_list_free(struct ColorList **ptr)
   *ptr = NULL;
 }
 
+/**
+ * mutt_color_free - Free a colour
+ * @param fg Foreground colour ID
+ * @param bg Background colour ID
+ *
+ * If there are no more users, the resource will be freed.
+ */
+void mutt_color_free(uint32_t fg, uint32_t bg)
+{
+  struct ColorList *q = NULL;
+
+  struct ColorList *p = Colors->user_colors;
+  while (p)
+  {
+    if ((p->fg == fg) && (p->bg == bg))
+    {
+      (p->count)--;
+      if (p->count > 0)
+        return;
+
+      Colors->num_user_colors--;
+      mutt_debug(LL_DEBUG1, "Color pairs used so far: %d\n", Colors->num_user_colors);
+
+      if (p == Colors->user_colors)
+      {
+        Colors->user_colors = Colors->user_colors->next;
+        FREE(&p);
+        return;
+      }
+      q = Colors->user_colors;
+      while (q)
+      {
+        if (q->next == p)
+        {
+          q->next = p->next;
+          FREE(&p);
+          return;
+        }
+        q = q->next;
+      }
+      /* can't get here */
+    }
+    p = p->next;
+  }
+}
+
 /**
  * color_line_new - Create a new ColorLine
  * @retval ptr Newly allocated ColorLine
@@ -490,52 +536,6 @@ int mutt_color_combine(uint32_t fg_attr, uint32_t bg_attr)
     return A_NORMAL;
   return mutt_color_alloc(fg, bg);
 }
-
-/**
- * mutt_color_free - Free a colour
- * @param fg Foreground colour ID
- * @param bg Background colour ID
- *
- * If there are no more users, the resource will be freed.
- */
-void mutt_color_free(uint32_t fg, uint32_t bg)
-{
-  struct ColorList *q = NULL;
-
-  struct ColorList *p = Colors->user_colors;
-  while (p)
-  {
-    if ((p->fg == fg) && (p->bg == bg))
-    {
-      (p->count)--;
-      if (p->count > 0)
-        return;
-
-      Colors->num_user_colors--;
-      mutt_debug(LL_DEBUG1, "Color pairs used so far: %d\n", Colors->num_user_colors);
-
-      if (p == Colors->user_colors)
-      {
-        Colors->user_colors = Colors->user_colors->next;
-        FREE(&p);
-        return;
-      }
-      q = Colors->user_colors;
-      while (q)
-      {
-        if (q->next == p)
-        {
-          q->next = p->next;
-          FREE(&p);
-          return;
-        }
-        q = q->next;
-      }
-      /* can't get here */
-    }
-    p = p->next;
-  }
-}
 #endif /* HAVE_COLOR */
 
 #ifdef HAVE_COLOR