[FFmpeg-devel] [PATCH] mem: prefer SIZE_MAX over INT_MAX in av_malloc() and av_realloc() checks

Reimar Döffinger Reimar.Doeffinger at gmx.de
Thu May 19 10:53:12 CEST 2011

On 19 May 2011, at 09:00, Stefano Sabatini <stefano.sabatini-lala at poste.it> wrote:
> On date Thursday 2011-05-19 08:20:11 +0200, Reimar Döffinger encoded:
>> On 19 May 2011, at 06:08, Michael Niedermayer <michaelni at gmx.at> wrote:
>>> On Thu, May 19, 2011 at 12:07:27AM +0200, Stefano Sabatini wrote:
>>>> Now the functions accepts size_t size rather than int values, so using
>>>> size_t is more correct.
>>> 2gb should be enough for everyone ;)
>>> seriously i think allocating more (currently) is likely a bug
>>> maybe in a few years rawvideo frames will need but until then its
>>> safer to not extend this limit
>>> thats IMHO
>> I agree. I also prefer for behaviour to differ as little as possible between 32 and 64 bit systems.
> buffers are used not only for frames, check #185.

Well, but that case is rather an argument for an even smaller value.
Since FFmpeg does not implement a cache, there shouldn't be any/many valid allocations significantly larger than the raw frame size.

> Also MAX_INT is not fixed as well, if you want to avoid 32/64-bit
> system difference you should rather use a define (FF_MAX_MALLOC_SIZE).

In reality INT_MAX is the same for all relevant systems.
But otherwise I would even consider a runtime-settable max. allocation size an interesting feature.

More information about the ffmpeg-devel mailing list