It no longer serves a useful purpose.
---

AFAICT this was added for MinGW at the beginning of the century.
MSVC does not need it, mingw-w64 does not need it. Some old Cygwin
1.7.x I had lying around did need it, however, a freshly installed
Cygwin 2.5.x does not need it. MinGW 3.22.1 needs it, which probably
only shows how obsolete MinGW really is. MinGW 3.22.1 is supposed to
be the last release before switching to the 5.x branch. One can only
hope (expect?) that they'll be a tad more current then.

 configure       |  5 -----
 libavutil/mem.c | 29 +++--------------------------
 2 files changed, 3 insertions(+), 31 deletions(-)

diff --git a/configure b/configure
index 66da1e4..290238a 100755
--- a/configure
+++ b/configure
@@ -293,7 +293,6 @@ Advanced options (experts only):
   --disable-safe-bitstream-reader
                            disable buffer boundary checking in bitreaders
                            (faster, but may crash)
-  --enable-memalign-hack   emulate memalign, interferes with memory debuggers
   --enable-sram            allow use of on-chip SRAM
 
 Optimization options (experts only):
@@ -1352,7 +1351,6 @@ CONFIG_LIST="
     $LIBRARY_LIST
     $PROGRAM_LIST
     $SUBSYSTEM_LIST
-    memalign_hack
     neon_clobber_test
     pic
     pod2man
@@ -5030,9 +5028,6 @@ enabled_all dxva2 CoTaskMemFree &&
     prepend avconv_libs $($ldflags_filter "-lole32") &&
     enable dxva2_lib
 
-! enabled_any memalign posix_memalign aligned_malloc &&
-    enabled simd_align_16 && enable memalign_hack
-
 map 'enabled $v && intrinsics=${v#intrinsics_}' $INTRINSICS_LIST
 
 for thread in $THREADS_LIST; do
diff --git a/libavutil/mem.c b/libavutil/mem.c
index 15c2880..0f506d3 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -62,22 +62,12 @@ void  free(void *ptr);
 void *av_malloc(size_t size)
 {
     void *ptr = NULL;
-#if CONFIG_MEMALIGN_HACK
-    long diff;
-#endif
 
     /* let's disallow possibly ambiguous cases */
     if (size > (INT_MAX - 32) || !size)
         return NULL;
 
-#if CONFIG_MEMALIGN_HACK
-    ptr = malloc(size + 32);
-    if (!ptr)
-        return ptr;
-    diff              = ((-(long)ptr - 1) & 31) + 1;
-    ptr               = (char *)ptr + diff;
-    ((char *)ptr)[-1] = diff;
-#elif HAVE_POSIX_MEMALIGN
+#if HAVE_POSIX_MEMALIGN
     if (posix_memalign(&ptr, 32, size))
         ptr = NULL;
 #elif HAVE_ALIGNED_MALLOC
@@ -116,21 +106,11 @@ void *av_malloc(size_t size)
 
 void *av_realloc(void *ptr, size_t size)
 {
-#if CONFIG_MEMALIGN_HACK
-    int diff;
-#endif
-
     /* let's disallow possibly ambiguous cases */
     if (size > (INT_MAX - 16))
         return NULL;
 
-#if CONFIG_MEMALIGN_HACK
-    //FIXME this isn't aligned correctly, though it probably isn't needed
-    if (!ptr)
-        return av_malloc(size);
-    diff = ((char *)ptr)[-1];
-    return (char *)realloc((char *)ptr - diff, size + diff) + diff;
-#elif HAVE_ALIGNED_MALLOC
+#if HAVE_ALIGNED_MALLOC
     return _aligned_realloc(ptr, size, 32);
 #else
     return realloc(ptr, size);
@@ -189,10 +169,7 @@ int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
 
 void av_free(void *ptr)
 {
-#if CONFIG_MEMALIGN_HACK
-    if (ptr)
-        free((char *)ptr - ((char *)ptr)[-1]);
-#elif HAVE_ALIGNED_MALLOC
+#if HAVE_ALIGNED_MALLOC
     _aligned_free(ptr);
 #else
     free(ptr);
-- 
2.7.3

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to