These names are always the same, so not using duplicates saves allocations, checks for the allocations as well as frees.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -964,28 +964,20 @@ static av_cold int fieldmatch_init(AVFilterContext *ctx) · 963 unmodified lines | ||
| 964 | 964 | { |
| 965 | 965 | const FieldMatchContext *fm = ctx->priv; |
| 966 | 966 | AVFilterPad pad = { |
| 967 | − .name = av_strdup("main"), | |
| 967 | + .name = "main", | |
| 968 | 968 | .type = AVMEDIA_TYPE_VIDEO, |
| 969 | 969 | .config_props = config_input, |
| 970 | 970 | }; |
| 971 | 971 | int ret; |
| 972 | 972 | |
| 973 | − if (!pad.name) | |
| 974 | − return AVERROR(ENOMEM); | |
| 975 | − if ((ret = ff_insert_inpad(ctx, INPUT_MAIN, &pad)) < 0) { | |
| 976 | − av_freep(&pad.name); | |
| 973 | + if ((ret = ff_insert_inpad(ctx, INPUT_MAIN, &pad)) < 0) | |
| 977 | 974 | return ret; |
| 978 | − } | |
| 979 | 975 | |
| 980 | 976 | if (fm->ppsrc) { |
| 981 | − pad.name = av_strdup("clean_src"); | |
| 977 | + pad.name = "clean_src"; | |
| 982 | 978 | pad.config_props = NULL; |
| 983 | − if (!pad.name) | |
| 984 | − return AVERROR(ENOMEM); | |
| 985 | − if ((ret = ff_insert_inpad(ctx, INPUT_CLEANSRC, &pad)) < 0) { | |
| 986 | − av_freep(&pad.name); | |
| 979 | + if ((ret = ff_insert_inpad(ctx, INPUT_CLEANSRC, &pad)) < 0) | |
| 987 | 980 | return ret; |
| 988 | − } | |
| 989 | 981 | } |
| 990 | 982 | |
| 991 | 983 | if ((fm->blockx & (fm->blockx - 1)) || |
| @@ -1004,7 +996,6 @@ static av_cold int fieldmatch_init(AVFilterContext *ctx) · 12 unmodified lines | ||
| 1004 | 996 | |
| 1005 | 997 | static av_cold void fieldmatch_uninit(AVFilterContext *ctx) |
| 1006 | 998 | { |
| 1007 | − int i; | |
| 1008 | 999 | FieldMatchContext *fm = ctx->priv; |
| 1009 | 1000 | |
| 1010 | 1001 | if (fm->prv != fm->src) |
| @@ -1021,8 +1012,6 @@ static av_cold void fieldmatch_uninit(AVFilterContext *ctx) · 10 unmodified lines | ||
| 1021 | 1012 | av_freep(&fm->cmask_data[0]); |
| 1022 | 1013 | av_freep(&fm->tbuffer); |
| 1023 | 1014 | av_freep(&fm->c_array); |
| 1024 | − for (i = 0; i < ctx->nb_inputs; i++) | |
| 1025 | − av_freep(&ctx->input_pads[i].name); | |
| 1026 | 1015 | } |
| 1027 | 1016 | |
| 1028 | 1017 | static int config_output(AVFilterLink *outlink) |