Commit 0c4a8fcf authored by michael's avatar michael

align av_realloc()


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@5992 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 09edf1a8
...@@ -101,22 +101,24 @@ void *av_malloc(unsigned int size) ...@@ -101,22 +101,24 @@ void *av_malloc(unsigned int size)
*/ */
void *av_realloc(void *ptr, unsigned int size) void *av_realloc(void *ptr, unsigned int size)
{ {
#ifdef MEMALIGN_HACK void *ptr2;
int diff;
#endif
/* let's disallow possible ambiguous cases */ /* let's disallow possible ambiguous cases */
if(size > (INT_MAX-16) ) if(size > (INT_MAX-16) )
return NULL; return NULL;
#ifdef MEMALIGN_HACK #ifndef MEMALIGN_HACK
//FIXME this isn't aligned correctly, though it probably isn't needed ptr= realloc(ptr, size);
if(!ptr) return av_malloc(size); if(((int)ptr&15) || !ptr)
diff= ((char*)ptr)[-1]; return ptr;
return realloc(ptr - diff, size + diff) + diff;
#else
return realloc(ptr, size);
#endif #endif
ptr2= av_malloc(size);
if(ptr && ptr2)
memcpy(ptr2, ptr, size);
av_free(ptr);
return ptr2;
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment