aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/mem.c
diff options
context:
space:
mode:
authorRonald S. Bultje <rsbultje@gmail.com>2012-06-18 14:37:02 +0100
committerMartin Storsjö <martin@martin.st>2012-06-19 10:08:00 +0300
commitbe1a839ca638e308748831fdc6fa0b7a7c8e94cf (patch)
tree3cb79480a8c52b5947797b71d486282c5aa21dbe /libavutil/mem.c
parent7146177d1812966b3e19025271965625ac7a054d (diff)
downloadffmpeg-be1a839ca638e308748831fdc6fa0b7a7c8e94cf.tar.gz
mem: add support for _aligned_malloc() as found on Windows
The check uses check_func_header, since this function is conditionally available depending on the targeted MSVCRT version. Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavutil/mem.c')
-rw-r--r--libavutil/mem.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libavutil/mem.c b/libavutil/mem.c
index bf1a542db8..0fe9f5422a 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -84,6 +84,8 @@ void *av_malloc(size_t size)
#elif HAVE_POSIX_MEMALIGN
if (posix_memalign(&ptr,32,size))
ptr = NULL;
+#elif HAVE_ALIGNED_MALLOC
+ ptr = _aligned_malloc(size, 32);
#elif HAVE_MEMALIGN
ptr = memalign(32,size);
/* Why 64?
@@ -131,6 +133,8 @@ void *av_realloc(void *ptr, size_t size)
if(!ptr) return av_malloc(size);
diff= ((char*)ptr)[-1];
return (char*)realloc((char*)ptr - diff, size + diff) + diff;
+#elif HAVE_ALIGNED_MALLOC
+ return _aligned_realloc(ptr, size, 32);
#else
return realloc(ptr, size);
#endif
@@ -141,6 +145,8 @@ void av_free(void *ptr)
#if CONFIG_MEMALIGN_HACK
if (ptr)
free((char*)ptr - ((char*)ptr)[-1]);
+#elif HAVE_ALIGNED_MALLOC
+ _aligned_free(ptr);
#else
free(ptr);
#endif