[FFmpeg-devel] [PATCH] swscale-example: Use av_{free, malloc} instead of the system ones.

Ramiro Polla ramiro.polla
Sun Aug 23 23:19:43 CEST 2009


On Sun, Aug 23, 2009 at 6:10 PM, Michael Niedermayer<michaelni at gmx.at> wrote:
> On Sun, Aug 23, 2009 at 05:52:36PM -0300, Ramiro Polla wrote:
>> On Sun, Aug 23, 2009 at 12:27 AM, Michael Niedermayer<michaelni at gmx.at> wrote:
>> > On Sat, Aug 22, 2009 at 05:30:14PM -0300, Ramiro Polla wrote:
>> >> $subj
>> >
>> >> ?swscale-example.c | ? 16 ++++++++--------
>> >> ?1 file changed, 8 insertions(+), 8 deletions(-)
>> >> 70f7e63ec4ab57403f986ccb76bbbb5239b18887 ?0005-Use-av_-free-alloc-instead-of-the-system-ones.patch
>> >> From 02fd6052b28190df853c04ba8ed19f848e9808a2 Mon Sep 17 00:00:00 2001
>> >> From: Ramiro Polla <ramiro.polla at gmail.com>
>> >> Date: Sat, 22 Aug 2009 16:24:51 -0300
>> >> Subject: [PATCH] Use av_{free,alloc} instead of the system ones.
>> >
>> > whats the point?
>>
>> Remove an if (data) to free data =)
>
> why would you need if(data) ?

Aren't there some libc's that don't check for NULL inside free()?
(that's what I always thought because of a comment in lavu/mem.c)

The code would end up like this:

for (i = 0; i < 4; i++) {
src[i]= malloc(srcStride[i]*srcH);
dst[i]= malloc(dstStride[i]*dstH);
out[i]= malloc(refStride[i]*h);
if (!src[i] || !dst[i] || !out[i])
    goto fail;
}
...

fail: /* normal end of function */
for (i = 0; i < 4; i++) {
free(src[i]);
free(dst[i]);
free(out[i]);
}

Of course if a libc that wouldn't like this really exists we could
always just use if(src[i]) free(src[i]); instead of av_free()...



More information about the ffmpeg-devel mailing list