On Mon, 2012-07-09 at 14:28 +0200, Luca Barbato wrote:
> On 07/09/2012 12:18 PM, Måns Rullgård wrote:
> > Tomas Härdin <tomas.har...@codemill.se> writes:
> > 
> >> On Sun, 2012-07-08 at 21:12 +0100, Måns Rullgård wrote:
> >>> Tomas Härdin <tomas.har...@codemill.se> writes:
> >>>> +void *av_calloc(size_t nmemb, size_t size)
> >>>> +{
> >>>> +    if (size <= 0 || nmemb >= INT_MAX / size)
> >>>> +        return NULL;
> >>>> +    return av_mallocz(nmemb * size);
> >>>> +}
> >>>
> >>> The places where this would be used don't in general need zeroed memory.
> >>
> >> Indeed, but calloc() zeroes memory so I'd say it's expected behavior.
> > 
> > That's a ridiculous argument.  Give the function another name.

That just like, your opinion, man.

> What about something along the lines of
> 
> #define av_malloc_array(nmemb, size) \
>     av_malloc((size <= 0 || nmemb >= INT_MAX / size) ? 0 : nmemb * size);


Wouldn't a static inline be better, should someone do something like
av_malloc_array(avio_rb32(pb), sizeof(Foo))?

But whatever. I don't want to bikeshed over this. Just keep in mind that
BS like this puts me off porting mxfdec patches that apply cleanly to
FFmpeg to Libav.

/Tomas

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to