[Ffmpeg-devel] [RFC] another attempt at memalign realloc
Reimar Döffinger
Reimar.Doeffinger
Thu Dec 7 13:09:51 CET 2006
Hello,
On Thu, Dec 07, 2006 at 12:55:47PM +0100, Michael Niedermayer wrote:
> > Too bad I can't find any good solution for the
> > non-memalign-hack case.
>
> p= realloc(p, size);
> if(!((long)p&15))
> return p;
> p2= av_malloc(size);
> if(p2)
> memcpy(p2, p, size);
> av_free(p);
> return p2;
>
> ?
>
> btw, this one with a small modification should work in the memalign-hack
> case too i think, would simplify the code though it would be slower in the
> memalign-hack case ...
Yes, I was thinking about that, and probably it is fine for ffmpeg, but
it does not meet this part of realloc:
"If realloc() fails the original block is left untouched".
If we do it this change, at least we must free p always and say
"If av_realloc() fails the original block is freed".
Unless of course I miss something *g*
Greetings,
Reimar D?ffinger
More information about the ffmpeg-devel
mailing list