| Re: [eigen] portable reallocation... |
[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]
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
>
Attachment:
mem_cleanup.patch
Description: Binary data
| Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |