diff mbox

[FFmpeg-devel,v1,1/6] avfilter/af_silencedetect: change parameters order for av_malllocz_array

Message ID 20190930133647.6290-1-lance.lmwang@gmail.com
State Superseded
Headers show

Commit Message

Lance Wang Sept. 30, 2019, 1:36 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavfilter/af_silencedetect.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Carl Eugen Hoyos Oct. 1, 2019, 11:23 a.m. UTC | #1
Am Mo., 30. Sept. 2019 um 15:37 Uhr schrieb <lance.lmwang@gmail.com>:
>
> From: Limin Wang <lance.lmwang@gmail.com>
>
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavfilter/af_silencedetect.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavfilter/af_silencedetect.c b/libavfilter/af_silencedetect.c
> index 3a71f39..c31109f 100644
> --- a/libavfilter/af_silencedetect.c
> +++ b/libavfilter/af_silencedetect.c
> @@ -143,10 +143,10 @@ static int config_input(AVFilterLink *inlink)
>
>      s->channels = inlink->channels;
>      s->independent_channels = s->mono ? s->channels : 1;
> -    s->nb_null_samples = av_mallocz_array(sizeof(*s->nb_null_samples), s->independent_channels);
> +    s->nb_null_samples = av_mallocz_array(s->independent_channels, sizeof(*s->nb_null_samples));
>      if (!s->nb_null_samples)
>          return AVERROR(ENOMEM);
> -    s->start = av_malloc_array(sizeof(*s->start), s->independent_channels);
> +    s->start = av_malloc_array(s->independent_channels, sizeof(*s->start));

Sorry if this is obvious:
Why?

Carl Eugen
Lance Wang Oct. 7, 2019, 2:28 p.m. UTC | #2
On Tue, Oct 01, 2019 at 01:23:04PM +0200, Carl Eugen Hoyos wrote:
> Am Mo., 30. Sept. 2019 um 15:37 Uhr schrieb <lance.lmwang@gmail.com>:
> >
> > From: Limin Wang <lance.lmwang@gmail.com>
> >
> > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > ---
> >  libavfilter/af_silencedetect.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavfilter/af_silencedetect.c b/libavfilter/af_silencedetect.c
> > index 3a71f39..c31109f 100644
> > --- a/libavfilter/af_silencedetect.c
> > +++ b/libavfilter/af_silencedetect.c
> > @@ -143,10 +143,10 @@ static int config_input(AVFilterLink *inlink)
> >
> >      s->channels = inlink->channels;
> >      s->independent_channels = s->mono ? s->channels : 1;
> > -    s->nb_null_samples = av_mallocz_array(sizeof(*s->nb_null_samples), s->independent_channels);
> > +    s->nb_null_samples = av_mallocz_array(s->independent_channels, sizeof(*s->nb_null_samples));
> >      if (!s->nb_null_samples)
> >          return AVERROR(ENOMEM);
> > -    s->start = av_malloc_array(sizeof(*s->start), s->independent_channels);
> > +    s->start = av_malloc_array(s->independent_channels, sizeof(*s->start));
> 
> Sorry if this is obvious:
> Why?
It's minor change, please corrent me if I'm misunderstanding. by description of the av_malloc_array parameters: 
  * @param nmemb Number of element
  * @param size  Size of a single element


> 
> Carl Eugen
> _______________________________________________
> 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".
Moritz Barsnick Oct. 7, 2019, 3:40 p.m. UTC | #3
On Mon, Oct 07, 2019 at 22:28:01 +0800, Limin Wang wrote:
> It's minor change, please corrent me if I'm misunderstanding. by description of the av_malloc_array parameters:
>   * @param nmemb Number of element
>   * @param size  Size of a single element

I agree that it's more true to the documentation, although there's
technically no (or very little) difference.

Alas, I found 17 such "reversed" uses in the code base, at a quick
glance.

Moritz
Lance Wang Oct. 7, 2019, 3:46 p.m. UTC | #4
On Mon, Oct 07, 2019 at 05:40:50PM +0200, Moritz Barsnick wrote:
> On Mon, Oct 07, 2019 at 22:28:01 +0800, Limin Wang wrote:
> > It's minor change, please corrent me if I'm misunderstanding. by description of the av_malloc_array parameters:
> >   * @param nmemb Number of element
> >   * @param size  Size of a single element
> 
> I agree that it's more true to the documentation, although there's
> technically no (or very little) difference.

OK, please ignore the patch if such usage is acceptable.

> 
> Alas, I found 17 such "reversed" uses in the code base, at a quick
> glance.
> 
> Moritz
> _______________________________________________
> 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

Patch

diff --git a/libavfilter/af_silencedetect.c b/libavfilter/af_silencedetect.c
index 3a71f39..c31109f 100644
--- a/libavfilter/af_silencedetect.c
+++ b/libavfilter/af_silencedetect.c
@@ -143,10 +143,10 @@  static int config_input(AVFilterLink *inlink)
 
     s->channels = inlink->channels;
     s->independent_channels = s->mono ? s->channels : 1;
-    s->nb_null_samples = av_mallocz_array(sizeof(*s->nb_null_samples), s->independent_channels);
+    s->nb_null_samples = av_mallocz_array(s->independent_channels, sizeof(*s->nb_null_samples));
     if (!s->nb_null_samples)
         return AVERROR(ENOMEM);
-    s->start = av_malloc_array(sizeof(*s->start), s->independent_channels);
+    s->start = av_malloc_array(s->independent_channels, sizeof(*s->start));
     if (!s->start)
         return AVERROR(ENOMEM);
     for (c = 0; c < s->independent_channels; c++)