[FFmpeg-devel] [PATCH] avutil/internal: add FF_ALLOC_ARRAY_OR_GOTO & FF_ALLOCZ_ARRAY_OR_GOTO

Michael Niedermayer michaelni at gmx.at
Fri Apr 18 15:54:42 CEST 2014


On Fri, Apr 18, 2014 at 03:34:54PM +0200, Clément Bœsch wrote:
> On Fri, Apr 18, 2014 at 03:26:04PM +0200, Michael Niedermayer wrote:
> > These are similar to the existing FF_ALLOCZ_OR_GOTO & FF_ALLOC_OR_GOTO
> > 
> > Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> > ---
> >  libavutil/internal.h |   18 ++++++++++++++++++
> >  1 file changed, 18 insertions(+)
> > 
> > diff --git a/libavutil/internal.h b/libavutil/internal.h
> > index 9c5546f..05a017f 100644
> > --- a/libavutil/internal.h
> > +++ b/libavutil/internal.h
> > @@ -133,6 +133,24 @@
> >      }\
> >  }
> >  
> > +#define FF_ALLOC_ARRAY_OR_GOTO(ctx, p, size0, size1, label)\
> > +{\
> 
> > +    p = av_malloc(size0, size1);\
> 
> ??

changed to av_malloc_array()


> 
> > +    if (p == NULL) {\
> > +        av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
> > +        goto label;\
> > +    }\
> > +}
> > +
> > +#define FF_ALLOCZ_ARRAY_OR_GOTO(ctx, p, size0, size1, label)\
> > +{\
> > +    p = av_mallocz(size0, size1);\
> 
> ditto..

changed to av_mallocz_array()


> 
> av_calloc maybe? Also in that case nmemb, n, or count for one of the size
> would be more appropriate.
> 
> > +    if (p == NULL) {\
> > +        av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
> > +        goto label;\
> > +    }\
> > +}
> > +
> >  #include "libm.h"
> 
> -- 
> Clément B.



> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140418/0eea3d30/attachment.asc>


More information about the ffmpeg-devel mailing list