summaryrefslogtreecommitdiff
path: root/libavutil/mem.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2006-08-13 00:47:16 +0000
committerMichael Niedermayer <michaelni@gmx.at>2006-08-13 00:47:16 +0000
commit75c413ae771878c26de312874197d14e73579a2e (patch)
tree9f59641a9c1e034a1b0c6b0d684ecac5fb1b37a0 /libavutil/mem.c
parent4bff9ef9d0781c4de228bf1f85634d2706fc589b (diff)
align av_realloc()
Originally committed as revision 5992 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil/mem.c')
-rw-r--r--libavutil/mem.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/libavutil/mem.c b/libavutil/mem.c
index 440328b7f1..61d886dc5d 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -101,22 +101,24 @@ void *av_malloc(unsigned int size)
*/
void *av_realloc(void *ptr, unsigned int size)
{
-#ifdef MEMALIGN_HACK
- int diff;
-#endif
+ void *ptr2;
/* let's disallow possible ambiguous cases */
if(size > (INT_MAX-16) )
return NULL;
-#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);
+#ifndef MEMALIGN_HACK
+ ptr= realloc(ptr, size);
+ if(((int)ptr&15) || !ptr)
+ return ptr;
#endif
+
+ ptr2= av_malloc(size);
+ if(ptr && ptr2)
+ memcpy(ptr2, ptr, size);
+ av_free(ptr);
+
+ return ptr2;
}
/**