[FFmpeg-cvslog] r11932 - trunk/libavutil/mem.c

benoit subversion
Thu Feb 14 09:16:07 CET 2008


Author: benoit
Date: Thu Feb 14 09:16:07 2008
New Revision: 11932

Log:
Avoid void*-arithmetic.
Patch by mvplayer: ffmpeg gmail com


Modified:
   trunk/libavutil/mem.c

Modified: trunk/libavutil/mem.c
==============================================================================
--- trunk/libavutil/mem.c	(original)
+++ trunk/libavutil/mem.c	Thu Feb 14 09:16:07 2008
@@ -55,7 +55,7 @@ void *av_malloc(unsigned int size)
     if(!ptr)
         return ptr;
     diff= ((-(long)ptr - 1)&15) + 1;
-    ptr += diff;
+    ptr = (char*)ptr + diff;
     ((char*)ptr)[-1]= diff;
 #elif defined (HAVE_MEMALIGN)
     ptr = memalign(16,size);
@@ -105,7 +105,7 @@ void *av_realloc(void *ptr, unsigned int
     //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;
+    return (char*)realloc((char*)ptr - diff, size + diff) + diff;
 #else
     return realloc(ptr, size);
 #endif
@@ -116,7 +116,7 @@ void av_free(void *ptr)
     /* XXX: this test should not be needed on most libcs */
     if (ptr)
 #ifdef CONFIG_MEMALIGN_HACK
-        free(ptr - ((char*)ptr)[-1]);
+        free((char*)ptr - ((char*)ptr)[-1]);
 #else
         free(ptr);
 #endif




More information about the ffmpeg-cvslog mailing list