[FFmpeg-devel] [PATCH] Use posix_memalign() instead of memalign()

Ramiro Polla ramiro.polla
Fri Dec 19 11:41:41 CET 2008


>> --- libavutil/mem.c   (revision 16223)
>> +++ libavutil/mem.c   (working copy)
>> @@ -57,6 +58,9 @@
>> +#elif defined (HAVE_POSIX_MEMALIGN)
>> +    if(posix_memalign(&ptr,16,size))
>> +        ptr = NULL;
>>  #elif defined (HAVE_MEMALIGN)
>
> NULL?  Am I missing the obvious here?

According to [0]:
Upon successful completion, posix_memalign() shall return zero;
otherwise, an error number shall be returned to indicate the error.

So it fails on non-zero, and ptr would be uninitialized.

I think

+    ptr = NULL;
+    posix_memalign(&ptr,16,size);

has the same effect and avoids an if.

Ramiro Polla

[0] http://www.opengroup.org/onlinepubs/000095399/functions/posix_memalign.html




More information about the ffmpeg-devel mailing list