[Ffmpeg-devel] [RFC] another attempt at memalign realloc
Thu Dec 7 19:35:19 CET 2006
On Thu, Dec 07, 2006 at 07:05:55PM +0100, Reimar D?ffinger wrote:
> On Thu, Dec 07, 2006 at 01:09:51PM +0100, Reimar D?ffinger wrote:
> > 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*
> Actually, there is a rather obvious solution.
> Disadvantage: av_realloc without MEMALIGN_HACK now _always_ has the time
> and space costs of av_malloc.
this is not good IMHO realloc() on a sane system should be pretty fast if
no actuall realloc is needed
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
If you really think that XML is the answer, then you definitly missunderstood
the question -- Attila Kinali
More information about the ffmpeg-devel