DragonFly bugs List (threaded) for 2004-10
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
Re: cu coredumps
On Wed, Oct 27, 2004 at 12:51:51PM -0400, Timour Ezeev wrote:
> 2. If you dont want to create a new pointer, swap pointers in plase,
> like this
>
> (int)tmp_cp ^= (int)cp; (int)cp ^= (int)tmp_cp; (int)tmp_cp ^=
> (int)cp;
> free(tmp_cp);
>
> or something similar :)
No, please don't. This is
(a) obscure and hard to read
(b) uses a depricated extension of GCC (lhs cast)
(c) depends on sizeof(int) == sizeof(void *)
(d) slower than the version with a local variable
If you don't want to add a variable for the whole function scope, do a
{
void *local_tmp = cp;
cp = tmp_cp;
tmp= cp;
}
which is both easier to read and faster.
Joerg
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]