[FFmpeg-devel] [PATCH][VAAPI][2/6] Add common data structures and helpers (take 3)

Michael Niedermayer michaelni
Wed Mar 11 01:38:32 CET 2009


On Mon, Mar 09, 2009 at 11:56:18AM +0100, Gwenole Beauchesne wrote:
> On Sun, 8 Mar 2009, Michael Niedermayer wrote:
> 
> >>> realloc() returning NULL means the original is still there just that
> >>> it failed re allocating it
> >>
> >> 7.20.3.4 indeed confirms what you say but I couldn't find a single
> >> code in lavc operating that way:
> >> new_buffer = av_*_realloc(buffer, new_size);
> >> if (!new_buffer) {
> >>      av_freep(&buffer);
> >>      // do whatever else/return -1
> >> }
> >> buffer = new_buffer;
> >>
> >> would this be what you had in mind?
> >
> > yes
> >
> > also it might make sense to add a
> > av_realloc_and_free()
> > that does free the original in case of fail and replace all code that
> > expects these semantics rather ...
> 
> why not make it the default behaviour for av_realloc(), though a user 
> could override that function? I mean, it's generally used as buffer= 
> av_realloc(buffer, new_size);

if av_realloc() did free the source buffer on failure there would be no
way to recover as the data would be gone ...


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The educated differ from the uneducated as much as the living from the
dead. -- Aristotle 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090311/865aa320/attachment.pgp>



More information about the ffmpeg-devel mailing list