Re: Double linked list with one pointer - Mailing list pgsql-hackers

From Greg Stark
Subject Re: Double linked list with one pointer
Date
Msg-id 87he0d0z6w.fsf@stark.dyndns.tv
Whole thread Raw
In response to Re: Double linked list with one pointer  ("Dann Corbit" <DCorbit@connx.com>)
Responses Re: Double linked list with one pointer  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
"Dann Corbit" <DCorbit@connx.com> writes:

> From the C-FAQ:
> 
> A:    Not portably, it doesn't.  It attempts to modify the variable a
>     twice between sequence points, so its behavior is undefined.

> 10.3:    How can I write a generic macro to swap two values?

Neither of these are really relevant, a) he's not talking about swapping
anyways, and b) there's no reason to try to write the linked list code in a
single statement or macro.

> but it will not work for floating-point values or pointers

Treating pointers as integers is technically nonportable but realistically you
would be pretty hard pressed to find any architecture anyone runs postgres on
where there isn't some integer datatype that you can cast both directions from
pointers safely.


Presumably if you wanted to do this you would implement it all in an
abstraction that hid all the details from calling code. You could even
implement gdb functions to help debugging. 


But that's a lot of effort for something postgres didn't even need in the
first place.

-- 
greg



pgsql-hackers by date:

Previous
From: Mark Kirkwood
Date:
Subject: Re: *sigh*
Next
From: Oleg Bartunov
Date:
Subject: Re: Call for pg_dump testing