[FFmpeg-cvslog] mem: fix memalign hack av_realloc()

Michael Niedermayer git at videolan.org
Fri Nov 4 13:22:20 CET 2011


ffmpeg | branch: release/0.8 | Michael Niedermayer <michaelni at gmx.at> | Tue Oct 11 22:03:19 2011 +0200| [5ae87280e219e843c71201c580780e8e30083559] | committer: Michael Niedermayer

mem: fix memalign hack av_realloc()

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit fc11927890f38445a950b453d24928525da0e61a)

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5ae87280e219e843c71201c580780e8e30083559
---

 libavutil/mem.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/libavutil/mem.c b/libavutil/mem.c
index a58f432..a53676c 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -137,7 +137,9 @@ void *av_realloc(void *ptr, size_t size)
     //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;
+    ptr= realloc((char*)ptr - diff, size + diff);
+    if(ptr) ptr = (char*)ptr + diff;
+    return ptr;
 #else
     return realloc(ptr, size + !size);
 #endif



More information about the ffmpeg-cvslog mailing list