diff mbox series

[FFmpeg-devel,10/19] avfilter/avf_aphasemeter: Don't allocate outpad names

Message ID 20200825140927.16433-10-andreas.rheinhardt@gmail.com
State Accepted
Commit 281b8187e355b42f86b7a62f0fe93e6093484051
Headers show
Series [FFmpeg-devel,01/19] avfilter/avfilter: Fix indentation | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Aug. 25, 2020, 2:09 p.m. UTC
These names are always the same, so not using duplicates saves
allocations, checks for the allocations as well as frees.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavfilter/avf_aphasemeter.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

Comments

Paul B Mahol Aug. 26, 2020, 8:20 p.m. UTC | #1
On 8/25/20, Andreas Rheinhardt <andreas.rheinhardt@gmail.com> wrote:
> These names are always the same, so not using duplicates saves
> allocations, checks for the allocations as well as frees.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavfilter/avf_aphasemeter.c | 19 ++++---------------
>  1 file changed, 4 insertions(+), 15 deletions(-)
>

LGTM

> diff --git a/libavfilter/avf_aphasemeter.c b/libavfilter/avf_aphasemeter.c
> index be0b2fb70f..53d1de29d3 100644
> --- a/libavfilter/avf_aphasemeter.c
> +++ b/libavfilter/avf_aphasemeter.c
> @@ -227,11 +227,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
> *in)
>  static av_cold void uninit(AVFilterContext *ctx)
>  {
>      AudioPhaseMeterContext *s = ctx->priv;
> -    int i;
>
>      av_frame_free(&s->out);
> -    for (i = 0; i < ctx->nb_outputs; i++)
> -        av_freep(&ctx->output_pads[i].name);
>  }
>
>  static av_cold int init(AVFilterContext *ctx)
> @@ -241,30 +238,22 @@ static av_cold int init(AVFilterContext *ctx)
>      int ret;
>
>      pad = (AVFilterPad){
> -        .name         = av_strdup("out0"),
> +        .name         = "out0",
>          .type         = AVMEDIA_TYPE_AUDIO,
>      };
> -    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->do_video) {
>          pad = (AVFilterPad){
> -            .name         = av_strdup("out1"),
> +            .name         = "out1",
>              .type         = AVMEDIA_TYPE_VIDEO,
>              .config_props = config_video_output,
>          };
> -        if (!pad.name)
> -            return AVERROR(ENOMEM);
>          ret = ff_insert_outpad(ctx, 1, &pad);
> -        if (ret < 0) {
> -            av_freep(&pad.name);
> +        if (ret < 0)
>              return ret;
> -        }
>      }
>
>      return 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 mbox series

Patch

diff --git a/libavfilter/avf_aphasemeter.c b/libavfilter/avf_aphasemeter.c
index be0b2fb70f..53d1de29d3 100644
--- a/libavfilter/avf_aphasemeter.c
+++ b/libavfilter/avf_aphasemeter.c
@@ -227,11 +227,8 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 static av_cold void uninit(AVFilterContext *ctx)
 {
     AudioPhaseMeterContext *s = ctx->priv;
-    int i;
 
     av_frame_free(&s->out);
-    for (i = 0; i < ctx->nb_outputs; i++)
-        av_freep(&ctx->output_pads[i].name);
 }
 
 static av_cold int init(AVFilterContext *ctx)
@@ -241,30 +238,22 @@  static av_cold int init(AVFilterContext *ctx)
     int ret;
 
     pad = (AVFilterPad){
-        .name         = av_strdup("out0"),
+        .name         = "out0",
         .type         = AVMEDIA_TYPE_AUDIO,
     };
-    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->do_video) {
         pad = (AVFilterPad){
-            .name         = av_strdup("out1"),
+            .name         = "out1",
             .type         = AVMEDIA_TYPE_VIDEO,
             .config_props = config_video_output,
         };
-        if (!pad.name)
-            return AVERROR(ENOMEM);
         ret = ff_insert_outpad(ctx, 1, &pad);
-        if (ret < 0) {
-            av_freep(&pad.name);
+        if (ret < 0)
             return ret;
-        }
     }
 
     return 0;