Re: [eigen] portable reallocation...

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Wait, one more comment.

The function name ei_handmade_aligned_realloc is unfortunate, since it
seems to suggests that it's the function for use with
ei_handmade_aligned_malloc.

So I would rather call it something like ei_generic_aligned_realloc.

Then, it would be interesting to actually code the
ei_handmade_aligned_realloc using std::realloc... indeed, in the
handmade case, that would give better realloc performance.

By the way, we also must call std::realloc and not realloc.

Benoit

2010/2/28 Benoit Jacob <jacob.benoit.1@xxxxxxxxx>:
> Great patch, just 1 comment:
>
> -    /*errno = ENOMEM;*/ // according to the standard we should set
> errno = ENOMEM
> +    errno = ENOMEM; // according to the standard
>
> Isn't it std::errno? Recently someone complained that the standard
> doesn't guarantee that the c++ headers will define these symbols in
> the global namespace, only in the std namespace. Putting std::
> everywhere was necessary to fix QNX/QCC compatibillity.
>
> OH WAIT!
>
> While we're at it, all the calls to free() must be replaced by std::free() !!
>
> Finally, let me re-ask (since either you didn't reply to that or I
> didn't understand the reply):
>  - how about moving MSVC's functions _aligned_... up in the priority list?
>
> Benoit
>
> 2010/2/28 Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>:
>> Here is a new patch. I found the navigation in Memory.h a little
>> complex so I tried to reorder the functions in order to achieve
>> better/cleaner grouping.
>>
>> - Hauke
>>
>> On Sun, Feb 28, 2010 at 11:55 AM, Hauke Heibel
>> <hauke.heibel@xxxxxxxxxxxxxx> wrote:
>>> So, how about this one (a single handmade version):
>>>
>>> inline void* ei_new_handmade_aligned_realloc(void* ptr, size_t size,
>>> size_t old_size)
>>> {
>>>  if (ptr==0)
>>>    return ei_aligned_malloc(size);
>>>
>>>  if (size==0)
>>>  {
>>>    ei_aligned_free(ptr);
>>>    return 0;
>>>  }
>>>
>>>  void* newptr = ei_aligned_malloc(size,16);
>>>  if (newptr == 0)
>>>  {
>>>    /*errno = ENOMEM;*/ // according to the standard we should set
>>> errno = ENOMEM
>>>    return 0;
>>>  }
>>>
>>>  if (ptr != 0)
>>>  {
>>>    std::memcpy(newptr, ptr, std::min(size,old_size));
>>>    ei_aligned_free(ptr);
>>>  }
>>>
>>>  return newptr;
>>> }
>>>
>>> - Hauke
>>>
>>
>



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/