From: Richard Russon Date: Sat, 31 Aug 2019 19:24:48 +0000 (+0100) Subject: myvarlist_free X-Git-Tag: 2019-10-25~63^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=37ce63ca192b1cb8a01ad2c58aefc991785b23ea;p=neomutt myvarlist_free --- diff --git a/main.c b/main.c index 22a58044b..adfaa8707 100644 --- a/main.c +++ b/main.c @@ -71,6 +71,7 @@ #include "mutt_window.h" #include "muttlib.h" #include "mx.h" +#include "myvar.h" #include "ncrypt/ncrypt.h" #include "options.h" #include "protos.h" @@ -1279,6 +1280,7 @@ main_exit: mutt_browser_cleanup(); mutt_opts_free(); mutt_keys_free(); + myvarlist_free(&MyVars); neomutt_free(&NeoMutt); cs_free(&Config); return rc; diff --git a/myvar.c b/myvar.c index b2c1957f3..26ec1d2b3 100644 --- a/myvar.c +++ b/myvar.c @@ -123,3 +123,21 @@ void myvar_del(const char *var) } } } + +/** + * myvarlist_free - Free a List of MyVars + * @param list List of MyVars + */ +void myvarlist_free(struct MyVarList *list) +{ + if (!list) + return; + + struct MyVar *myv = NULL; + struct MyVar *tmp = NULL; + TAILQ_FOREACH_SAFE(myv, list, entries, tmp) + { + TAILQ_REMOVE(list, myv, entries); + myvar_free(&myv); + } +} diff --git a/myvar.h b/myvar.h index 80eb2c84b..26b640681 100644 --- a/myvar.h +++ b/myvar.h @@ -42,4 +42,6 @@ void myvar_del(const char *var); const char *myvar_get(const char *var); void myvar_set(const char *var, const char *val); +void myvarlist_free(struct MyVarList *list); + #endif /* MUTT_MYVAR_H */