aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/mem.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2006-08-17 08:18:48 +0000
committerMichael Niedermayer <michaelni@gmx.at>2006-08-17 08:18:48 +0000
commit0a7c36af5431bc86e8e4a53e652002acd0079ffa (patch)
tree8f701139e43e9528c1b57e474ca8ed92f82289fa /libavutil/mem.c
parent2287c100b238a9288d4f8de14de0cc0d0c854917 (diff)
downloadffmpeg-0a7c36af5431bc86e8e4a53e652002acd0079ffa.tar.gz
revert aligned realloc() changesm this should be identical to r5784
Originally committed as revision 6008 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil/mem.c')
-rw-r--r--libavutil/mem.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/libavutil/mem.c b/libavutil/mem.c
index cdfefd6055..440328b7f1 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -50,7 +50,7 @@ void *av_malloc(unsigned int size)
#endif
/* let's disallow possible ambiguous cases */
- if(size > (INT_MAX-16) || !size)
+ if(size > (INT_MAX-16) )
return NULL;
#ifdef MEMALIGN_HACK
@@ -101,26 +101,22 @@ void *av_malloc(unsigned int size)
*/
void *av_realloc(void *ptr, unsigned int size)
{
- void *ptr2;
+#ifdef MEMALIGN_HACK
+ int diff;
+#endif
/* let's disallow possible ambiguous cases */
if(size > (INT_MAX-16) )
return NULL;
-#ifndef MEMALIGN_HACK
- ptr= realloc(ptr, size);
-assert(((int)((void*)0)&15) == 0); //for the null pointer pedants
- if(!((int)ptr&15))
- return ptr;
+#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);
#endif
-
- ptr2= av_malloc(size);
- if(ptr && ptr2)
- memcpy(ptr2, ptr, size);
- if(ptr2 || !size)
- av_free(ptr);
-
- return ptr2;
}
/**