[Ffmpeg-cvslog] r5996 - trunk/libavutil/mem.c

Michael Niedermayer michaelni
Fri Oct 20 01:29:34 CEST 2006


Hi

On Tue, Aug 15, 2006 at 06:23:17PM +0200, Reimar D?ffinger wrote:
> Hello,
> On Sun, Aug 13, 2006 at 11:09:00PM +0200, michael wrote:
> >  #ifndef MEMALIGN_HACK
> >      ptr= realloc(ptr, size);
> > -    if(((int)ptr&15) || !ptr)
> > +assert(((int)((void*)0)&15) == 0); //for the null pointer pedants
> > +    if(!((int)ptr&15))
> >          return ptr;
> >  #endif
> >  
> >      ptr2= av_malloc(size);
> >      if(ptr && ptr2)
> >          memcpy(ptr2, ptr, size);
> 
> This would have to be the minimum of the size for ptr and ptr2,
> unfortunately we don't know that for ptr.
> No idea what would be a good way to fix it...

ptr=realloc(ptr, size) (or equivalent for MEMALIGN_HACK)
if(!((int)ptr&15))
    return ptr;

ptr2= av_malloc(size);
if(ptr && ptr2)
    memcpy(ptr2, ptr, size);
av_free(ptr);
return ptr2;

the difference to the old ... we realloc() first so we know that the "old"
size will be equal to the new ...

note, iam too lazy to test and commit this (especially before the mplayer
release ...)

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is




More information about the ffmpeg-cvslog mailing list