[FFmpeg-devel] [PATCH] Handle build environment where both posix_malloc and _aligned_alloc are available

Andrey Turkin andrey.turkin at gmail.com
Thu Feb 23 12:07:27 EET 2017


av_malloc prefers posix_malloc over _aligned_alloc so realloc and free functions must be used when posix_malloc is available. This fixes mingw32 builds when using custom allocators.
---
 libavutil/mem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/mem.c b/libavutil/mem.c
index 1a8fc21e98..d0065a09d5 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -162,7 +162,7 @@ void *av_realloc(void *ptr, size_t size)
     if (ptr)
         ptr = (char *)ptr + diff;
     return ptr;
-#elif HAVE_ALIGNED_MALLOC
+#elif HAVE_ALIGNED_MALLOC && !HAVE_POSIX_MEMALIGN
     return _aligned_realloc(ptr, size + !size, ALIGN);
 #else
     return realloc(ptr, size + !size);
@@ -233,7 +233,7 @@ void av_free(void *ptr)
         av_assert0(v>0 && v<=ALIGN);
         free((char *)ptr - v);
     }
-#elif HAVE_ALIGNED_MALLOC
+#elif HAVE_ALIGNED_MALLOC && !HAVE_POSIX_MEMALIGN
     _aligned_free(ptr);
 #else
     free(ptr);
-- 
2.11.0



More information about the ffmpeg-devel mailing list