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

index 967a467e564bfca5d6573fd14c7b3bb93b1e6108..ca36a1121f8292f2d87859e55830dc49e8b8bf32 100644 (file)
--- a/keymap.c
+++ b/keymap.c
@@ -149,6 +149,8 @@ int LastKey; /**< contains the last key the user pressed */
 struct Keymap *Keymaps[MENU_MAX];
 struct KeymapList *NewKeymaps[MENU_MAX];
 
+static void mutt_keymap_free(struct Keymap **km);
+
 /**
  * alloc_keys - Allocate space for a sequence of keys
  * @param len  Number of keys
@@ -342,10 +344,7 @@ static enum CommandResult km_bind_err(const char *s, enum MenuType menu, int op,
         }
         len = tmp->eq;
         next = tmp->next;
-        FREE(&tmp->macro);
-        FREE(&tmp->keys);
-        FREE(&tmp->desc);
-        FREE(&tmp);
+        mutt_keymap_free(&tmp);
         tmp = next;
       } while (tmp && len >= pos);
       map->eq = len;
@@ -1609,13 +1608,25 @@ void mutt_keys_free(void)
     for (map = Keymaps[i]; map; map = next)
     {
       next = map->next;
-
-      FREE(&map->macro);
-      FREE(&map->desc);
-      FREE(&map->keys);
-      FREE(&map);
+      mutt_keymap_free(&map);
     }
 
     Keymaps[i] = NULL;
   }
 }
+
+
+/**
+ * mutt_keymap_free - Free a Keymap
+ * @param km Keymap to free
+ */
+static void mutt_keymap_free(struct Keymap **km)
+{
+  if (!km || !*km)
+    return;
+
+  FREE(&(*km)->macro);
+  FREE(&(*km)->desc);
+  FREE(&(*km)->keys);
+  FREE(km);
+}