Re: [eigen] portable reallocation... |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] portable reallocation...
- From: Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>
- Date: Sun, 28 Feb 2010 11:55:39 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=THSHC8sN+d/m6P6c9IXfZHKXU9prX3qsmg+fDuuFyok=; b=Xt4lyLcwQZAzxVKSRNiasTNCpHGXpCiCE3fc8Y5xpEBhzOD8mqEcfRaW0+1bjJVw8Z IuPnSevU+ApiqpidxJrf4zkDx+zYItSmdZXcP2am9Pkya8ZUphMgH3/ZJBdDEY3s+9I2 LHM5l7WR+HhOFuZ0oxDDs+hytkHaARIOeV1Hg=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=mkKqCo4zoOBmAZjx7krDctjvPYsHXonsAy1d6SyWCSKwq1qSPuBzNPnZ0v8/d9AUDQ PTO/64m10cgCyl5mn4qGYUUIwGiyBHWPLTpZ5v8S0rMKhqmtTSnBsyQ74TnngTPq3Rma wt13pdZX5CPYB6t7lSRygqeW0IaPlTOvJReGM=
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