Message ID | 20200825140927.16433-12-andreas.rheinhardt@gmail.com |
---|---|
State | Accepted |
Commit | 4c5d6e87acf764893827ea0e3790ef5711878a79 |
Headers | show |
Series | [FFmpeg-devel,01/19] avfilter/avfilter: Fix indentation | expand |
Context | Check | Description |
---|---|---|
andriy/default | pending | |
andriy/make | success | Make finished |
andriy/make_fate | success | Make fate finished |
On 8/25/20, Andreas Rheinhardt <andreas.rheinhardt@gmail.com> wrote: > If the names are always the same, they need not be duplicated; doing so > saves allocations, checks for the allocations as well as frees. > > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> > --- > libavfilter/af_afir.c | 30 +++++++----------------------- > 1 file changed, 7 insertions(+), 23 deletions(-) > LGTM > diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c > index 4e76bda4a3..d128f4bce7 100644 > --- a/libavfilter/af_afir.c > +++ b/libavfilter/af_afir.c > @@ -800,11 +800,9 @@ static av_cold void uninit(AVFilterContext *ctx) > av_frame_free(&s->ir[i]); > } > > - for (int i = 0; i < ctx->nb_inputs; i++) > + for (unsigned i = 1; i < ctx->nb_inputs; i++) > av_freep(&ctx->input_pads[i].name); > > - for (int i = 0; i < ctx->nb_outputs; i++) > - av_freep(&ctx->output_pads[i].name); > av_frame_free(&s->video); > } > > @@ -842,18 +840,13 @@ static av_cold int init(AVFilterContext *ctx) > int ret; > > pad = (AVFilterPad) { > - .name = av_strdup("main"), > + .name = "main", > .type = AVMEDIA_TYPE_AUDIO, > }; > > - if (!pad.name) > - return AVERROR(ENOMEM); > - > ret = ff_insert_inpad(ctx, 0, &pad); > - if (ret < 0) { > - av_freep(&pad.name); > + if (ret < 0) > return ret; > - } > > for (int n = 0; n < s->nb_irs; n++) { > pad = (AVFilterPad) { > @@ -872,34 +865,25 @@ static av_cold int init(AVFilterContext *ctx) > } > > pad = (AVFilterPad) { > - .name = av_strdup("default"), > + .name = "default", > .type = AVMEDIA_TYPE_AUDIO, > .config_props = config_output, > }; > > - if (!pad.name) > - return AVERROR(ENOMEM); > - > ret = ff_insert_outpad(ctx, 0, &pad); > - if (ret < 0) { > - av_freep(&pad.name); > + if (ret < 0) > return ret; > - } > > if (s->response) { > vpad = (AVFilterPad){ > - .name = av_strdup("filter_response"), > + .name = "filter_response", > .type = AVMEDIA_TYPE_VIDEO, > .config_props = config_video, > }; > - if (!vpad.name) > - return AVERROR(ENOMEM); > > ret = ff_insert_outpad(ctx, 1, &vpad); > - if (ret < 0) { > - av_freep(&vpad.name); > + if (ret < 0) > return ret; > - } > } > > s->fdsp = avpriv_float_dsp_alloc(0); > -- > 2.20.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c index 4e76bda4a3..d128f4bce7 100644 --- a/libavfilter/af_afir.c +++ b/libavfilter/af_afir.c @@ -800,11 +800,9 @@ static av_cold void uninit(AVFilterContext *ctx) av_frame_free(&s->ir[i]); } - for (int i = 0; i < ctx->nb_inputs; i++) + for (unsigned i = 1; i < ctx->nb_inputs; i++) av_freep(&ctx->input_pads[i].name); - for (int i = 0; i < ctx->nb_outputs; i++) - av_freep(&ctx->output_pads[i].name); av_frame_free(&s->video); } @@ -842,18 +840,13 @@ static av_cold int init(AVFilterContext *ctx) int ret; pad = (AVFilterPad) { - .name = av_strdup("main"), + .name = "main", .type = AVMEDIA_TYPE_AUDIO, }; - if (!pad.name) - return AVERROR(ENOMEM); - ret = ff_insert_inpad(ctx, 0, &pad); - if (ret < 0) { - av_freep(&pad.name); + if (ret < 0) return ret; - } for (int n = 0; n < s->nb_irs; n++) { pad = (AVFilterPad) { @@ -872,34 +865,25 @@ static av_cold int init(AVFilterContext *ctx) } pad = (AVFilterPad) { - .name = av_strdup("default"), + .name = "default", .type = AVMEDIA_TYPE_AUDIO, .config_props = config_output, }; - if (!pad.name) - return AVERROR(ENOMEM); - ret = ff_insert_outpad(ctx, 0, &pad); - if (ret < 0) { - av_freep(&pad.name); + if (ret < 0) return ret; - } if (s->response) { vpad = (AVFilterPad){ - .name = av_strdup("filter_response"), + .name = "filter_response", .type = AVMEDIA_TYPE_VIDEO, .config_props = config_video, }; - if (!vpad.name) - return AVERROR(ENOMEM); ret = ff_insert_outpad(ctx, 1, &vpad); - if (ret < 0) { - av_freep(&vpad.name); + if (ret < 0) return ret; - } } s->fdsp = avpriv_float_dsp_alloc(0);
If the names are always the same, they need not be duplicated; doing so saves allocations, checks for the allocations as well as frees. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> --- libavfilter/af_afir.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-)