]> granicus.if.org Git - neomutt/commitdiff
Extract static 'mutt_keymapslist_free' procedure devel/issue-1179
authorVladimir Zakharov <zakharov.vv@gmail.com>
Thu, 9 Aug 2018 20:54:20 +0000 (23:54 +0300)
committerRichard Russon <rich@flatcap.org>
Mon, 21 Oct 2019 19:03:34 +0000 (20:03 +0100)
keymap.c

index ca36a1121f8292f2d87859e55830dc49e8b8bf32..f4157d3d5b1ae698cbca549eb1679655e18579af 100644 (file)
--- a/keymap.c
+++ b/keymap.c
@@ -150,6 +150,7 @@ struct Keymap *Keymaps[MENU_MAX];
 struct KeymapList *NewKeymaps[MENU_MAX];
 
 static void mutt_keymap_free(struct Keymap **km);
+static void mutt_keymaplist_free(struct Keymap **km_list);
 
 /**
  * alloc_keys - Allocate space for a sequence of keys
@@ -1600,22 +1601,12 @@ void mutt_what_key(void)
  */
 void mutt_keys_free(void)
 {
-  struct Keymap *map = NULL;
-  struct Keymap *next = NULL;
-
   for (int i = 0; i < MENU_MAX; i++)
   {
-    for (map = Keymaps[i]; map; map = next)
-    {
-      next = map->next;
-      mutt_keymap_free(&map);
-    }
-
-    Keymaps[i] = NULL;
+    mutt_keymaplist_free(&Keymaps[i]);
   }
 }
 
-
 /**
  * mutt_keymap_free - Free a Keymap
  * @param km Keymap to free
@@ -1630,3 +1621,19 @@ static void mutt_keymap_free(struct Keymap **km)
   FREE(&(*km)->keys);
   FREE(km);
 }
+
+/**
+ * mutt_keymaplist_free - Free a List of Keymaps
+ * @param km_list List of Keymaps to free
+ */
+static void mutt_keymaplist_free(struct Keymap **km_list)
+{
+  struct Keymap *map = NULL;
+  struct Keymap *next = NULL;
+  for (map = (*km_list); map; map = next)
+  {
+    next = map->next;
+    mutt_keymap_free(&map);
+  }
+  *km_list = NULL;
+}