On 07/09/2012 12:18 PM, Måns Rullgård wrote:
> Tomas Härdin <[email protected]> writes:
> 
>> On Sun, 2012-07-08 at 21:12 +0100, Måns Rullgård wrote:
>>> Tomas Härdin <[email protected]> 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.
> 

What about something along the lines of

#define av_malloc_array(nmemb, size) \
    av_malloc((size <= 0 || nmemb >= INT_MAX / size) ? 0 : nmemb * size);

lu

-- 

Luca Barbato
Gentoo/linux
http://dev.gentoo.org/~lu_zero

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to