[FFmpeg-devel] Patch: avoid "void * " in pointer calculate

mvplayer ffmpeg
Wed Feb 13 14:29:46 CET 2008


As $subject

Index: libavutil/mem.c
===================================================================
--- libavutil/mem.c ?r11925?
+++ libavutil/mem.c ?working?
@@ -41,7 +41,7 @@

 void *av_malloc(unsigned int size)
 {
-    void *ptr;
+    char *ptr;
 #ifdef CONFIG_MEMALIGN_HACK
     long diff;
 #endif
@@ -91,10 +91,11 @@
     return ptr;
 }

-void *av_realloc(void *ptr, unsigned int size)
+void *av_realloc(void *ptr1, unsigned int size)
 {
 #ifdef CONFIG_MEMALIGN_HACK
     int diff;
+    char *ptr = ptr1;
 #endif

     /* let's disallow possible ambiguous cases */
@@ -105,9 +106,9 @@
     //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(ptr - diff, size + diff) + diff;
 #else
-    return realloc(ptr, size);
+    return realloc(ptr1, size);
 #endif
 }

@@ -116,7 +117,7 @@
     /* 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

-- 
----------------------------------------
Inspired by http://www.mvplayer.net




More information about the ffmpeg-devel mailing list