[Ffmpeg-cvslog] r6008 - trunk/libavutil/mem.c

michael subversion
Thu Aug 17 10:18:48 CEST 2006


Author: michael
Date: Thu Aug 17 10:18:48 2006
New Revision: 6008

Modified:
   trunk/libavutil/mem.c

Log:
revert aligned realloc() changesm this should be identical to r5784


Modified: trunk/libavutil/mem.c
==============================================================================
--- trunk/libavutil/mem.c	(original)
+++ trunk/libavutil/mem.c	Thu Aug 17 10:18:48 2006
@@ -50,7 +50,7 @@
 #endif
 
     /* let's disallow possible ambiguous cases */
-    if(size > (INT_MAX-16) || !size)
+    if(size > (INT_MAX-16) )
         return NULL;
 
 #ifdef MEMALIGN_HACK
@@ -101,26 +101,22 @@
  */
 void *av_realloc(void *ptr, unsigned int size)
 {
-    void *ptr2;
+#ifdef MEMALIGN_HACK
+    int diff;
+#endif
 
     /* let's disallow possible ambiguous cases */
     if(size > (INT_MAX-16) )
         return NULL;
 
-#ifndef MEMALIGN_HACK
-    ptr= realloc(ptr, size);
-assert(((int)((void*)0)&15) == 0); //for the null pointer pedants
-    if(!((int)ptr&15))
-        return ptr;
+#ifdef 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 realloc(ptr - diff, size + diff) + diff;
+#else
+    return realloc(ptr, size);
 #endif
-
-    ptr2= av_malloc(size);
-    if(ptr && ptr2)
-        memcpy(ptr2, ptr, size);
-    if(ptr2 || !size)
-        av_free(ptr);
-
-    return ptr2;
 }
 
 /**




More information about the ffmpeg-cvslog mailing list