[FFmpeg-devel] [PATCH] lavu/buffer: add release function

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Mar 2 17:14:48 CET 2014


On 28.02.2014, at 01:21, Lukasz Marek <lukasz.m.luki at gmail.com> wrote:
>> Keep in mind that a buffer can come from a user application. There is
>> no way you could free such a buffer correctly by destroying the buffer
>> reference and just returning the raw data.
> 
> I don't get it.

This buffer might be allocated on some special hardware, and to allocate/lock or deallocate/unlock it you need to write some magic registers.
What happens if you use this function on such a buffer?
I can see only two things happen:
1) you call the custom free function, then all following code trying to use it will cause bus errors or worse
2) you don't call it. Then the external hardware will forever stay in a locked state which essentialy might mean it will hang

The only way I can even see this working is if you assume that the buffer was allocated with an ordinary memory managment function like malloc, but that is nothing you can assume in general.


More information about the ffmpeg-devel mailing list