[vlc-commits] avcodec: use config_ChainDestroy to simplify the code

Zhao Zhili git at videolan.org
Fri Oct 16 09:43:25 CEST 2020


vlc | branch: master | Zhao Zhili <quinkblack at foxmail.com> | Thu Oct  1 18:47:00 2020 +0200| [0048a9a79cc7c284caaf3fd957efbf7bb84002f3] | committer: Steve Lhomme

avcodec: use config_ChainDestroy to simplify the code

Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0048a9a79cc7c284caaf3fd957efbf7bb84002f3
---

 modules/codec/avcodec/avcommon.h | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/modules/codec/avcodec/avcommon.h b/modules/codec/avcodec/avcommon.h
index 6d88f12d72..6c0c88704c 100644
--- a/modules/codec/avcodec/avcommon.h
+++ b/modules/codec/avcodec/avcommon.h
@@ -66,14 +66,11 @@ static inline void vlc_av_get_options(const char *psz_opts, AVDictionary** pp_di
 {
     config_chain_t *cfg = NULL;
     config_ChainParseOptions(&cfg, psz_opts);
-    while (cfg) {
-        config_chain_t *next = cfg->p_next;
-        av_dict_set(pp_dict, cfg->psz_name, cfg->psz_value, 0);
-        free(cfg->psz_name);
-        free(cfg->psz_value);
-        free(cfg);
-        cfg = next;
+    for (config_chain_t *item = cfg; item != NULL; item = item->p_next) {
+        av_dict_set(pp_dict, item->psz_name, item->psz_value, 0);
     }
+    if (cfg)
+        config_ChainDestroy(cfg);
 }
 
 static inline void vlc_init_avutil(vlc_object_t *obj)



More information about the vlc-commits mailing list