diff mbox

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

Message ID 20170223100727.26260-1-andrey.turkin@gmail.com
State New
Headers show

Commit Message

Andrey Turkin Feb. 23, 2017, 10:07 a.m. UTC
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 mbox

Patch

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);