[Ffmpeg-devel] [RFC] another attempt at memalign realloc

Michael Niedermayer michaelni
Wed Dec 6 22:02:43 CET 2006


Hi

On Wed, Dec 06, 2006 at 08:52:32PM +0000, M?ns Rullg?rd wrote:
> Michael Niedermayer <michaelni at gmx.at> writes:
> 
> > Hi
> >
> > On Wed, Dec 06, 2006 at 05:34:12PM +0100, Reimar D?ffinger wrote:
> >> Hello,
> >> I came up with the attached idea, but it seems so simple that I can't
> >> get rid of the feeling there is yet another problem with that (except
> >> that the performance might be really bad), otherwise somebody should
> >> have had that same idea during all this wild hacking around on it *g*.
> >> Well, please help me and have a very close look at it and say what you
> >> think.
> >> 
> >> Greetings,
> >> Reimar D?ffinger
> >
> >> Index: libavutil/mem.c
> >> ===================================================================
> >> --- libavutil/mem.c	(revision 7217)
> >> +++ libavutil/mem.c	(working copy)
> >> @@ -105,6 +105,7 @@
> >>  {
> >>  #ifdef CONFIG_MEMALIGN_HACK
> >>      int diff;
> >> +    void *ptr2;
> >>  #endif
> >>  
> >>      /* let's disallow possible ambiguous cases */
> >> @@ -112,10 +113,17 @@
> >>          return NULL;
> >>  
> >>  #ifdef CONFIG_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;
> >> +    ptr2 = realloc(ptr - diff, size + 16) + diff;
> >> +    if(!((int)ptr2&15))
> >
> > hmm didnt this cast cause same silly warning with gcc on x86-64 or
> > something, anyway long and int casts are mixed not a real issue though
> 
> GCC fusses about cast from pointer to integer of different size.  In
> this case it really doesn't matter, since we are only interested in
> the lower 4 bits.  Using intptr_t instead would probably make the
> warning go away.

IIRC intptr_t is optional in the c standard so this is not a good idea

[...]
-- 
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 mailing list