[FFmpeg-devel] [PATCH] [RFC] libavutil/mem.c: Check return value of posix_memalign

Måns Rullgård mans
Fri Feb 13 16:18:00 CET 2009


Patrik Kullman <patrik at yes.nu> writes:

> In my hunt to fix compilation warnings for ffmpeg, learn ffmpeg
> internals and learn C, I've come up with the patch to get rid of the
> "warn_unused_result" warning for mem.c
>
> Possibly horribly wrong ;)
>
> Index: libavutil/mem.c
> ===================================================================
> --- libavutil/mem.c	(revision 17209)
> +++ libavutil/mem.c	(working copy)
> @@ -63,7 +63,12 @@
>      ptr = (char*)ptr + diff;
>      ((char*)ptr)[-1]= diff;
>  #elif HAVE_POSIX_MEMALIGN
> -    posix_memalign(&ptr,16,size);
> +    if (posix_memalign(&ptr,16,size) != 0)
> +#if HAVE_MEMALIGN
> +        ptr = memalign(16,size);
> +#else
> +        ptr = malloc(size);
> +#endif
>  #elif HAVE_MEMALIGN
>      ptr = memalign(16,size);
>      /* Why 64?

What is the warning?

-- 
M?ns Rullg?rd
mans at mansr.com




More information about the ffmpeg-devel mailing list