[vlc-devel] [PATCH 2/4] avcodec: use config_ChainDestroy to simplify the code
Zhao Zhili
quinkblack at foxmail.com
Fri Oct 2 10:20:12 CEST 2020
On 10/2/20 2:52 PM, Steve Lhomme wrote:
> On 2020-10-01 18:47, Zhao Zhili wrote:
>> ---
>> 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..d9f46d577c 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)
>
> You don't really need the if here. config_ChainDestroy() already
> checks that.
Yes, but that's in the implementation, not specified in the
documentation explicitly. src/audio_output/filters.c does the same check
too.
>
>> + config_ChainDestroy(cfg);
>> }
>> static inline void vlc_init_avutil(vlc_object_t *obj)
>> --
>> 2.25.1
>>
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
>>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list