From: Vladimir Zakharov Date: Thu, 9 Aug 2018 20:39:53 +0000 (+0300) Subject: Extract static 'mutt_keymap_free' procedure X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b0b6716414ada2d85987bdc3f5400e056bb22fc0;p=neomutt Extract static 'mutt_keymap_free' procedure --- diff --git a/keymap.c b/keymap.c index 967a467e5..ca36a1121 100644 --- 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); +}