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

Måns Rullgård mru
Wed Dec 6 21:52:32 CET 2006


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.

-- 
M?ns Rullg?rd
mru at inprovide.com




More information about the ffmpeg-devel mailing list