[FFmpeg-devel] [PATCH] *alloc(type)

Reimar Döffinger Reimar.Doeffinger
Sat Nov 20 19:38:54 CET 2010


On Sat, Nov 20, 2010 at 12:56:14PM -0500, Ronald S. Bultje wrote:
> > Uh, failing when someone tries to allocate 4.5 GB instead of claiming
> > success while only returning 500 MB is "no good reason"?
> 
> The type is unsigned int. How did you get a >32-bit number in there in
> the first place? I think you should fix the caller.

Sure, but there's an advantage to making bugs impossible in the first
place.
The caller might be using a 64 bit value to avoid integer overflows.

> Where in lavc/f/u is it so difficult to check the value of the number
> of bytes allocated that we have to do it for all cases, even though
> most don't need it (think avi, or think static allocations such as
> sizeof(struct bla))? Or can't you write a wrapper around it
> (av_malloc64()) if you really want to for the few cases where the
> number could potentially be >32bits?

I'd like to know why you consider any of these _better_ than
always checking. I'd consider it vastly worse actually...
I also find the performance argument rather strange, considering
the overall slowness of malloc the slowdown due to a 64 bit type
and extra checks seems almost irrelevant to me...

> Again, what is the bug you're trying to fix? The _real_ bug, not the
> imaginary one.

None, but if we are changing it anyway...



More information about the ffmpeg-devel mailing list