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

Michael Niedermayer git at videolan.org
Sun Nov 6 20:18:56 CET 2011


ffmpeg | branch: release/0.5 | Michael Niedermayer <michaelni at gmx.at> | Tue Oct 11 22:03:19 2011 +0200| [36e4be0a0adc18358a59043167a55da8eac16023] | 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>
(cherry picked from commit 5ae87280e219e843c71201c580780e8e30083559)

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

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

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

diff --git a/libavutil/mem.c b/libavutil/mem.c
index 741450b..1ce0b77 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -113,7 +113,9 @@ void *av_realloc(void *ptr, unsigned int 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);
 #endif



More information about the ffmpeg-cvslog mailing list