glib dependency for the X Server

Bernardo Innocenti bernie at develer.com
Wed Apr 5 11:31:53 PDT 2006


Carsten Haitzler (The Rasterman) wrote:

>> What's disappointing here is that having the do NULL pointer checks on
>> list element pointers was solved 20 years ago on the Amiga.
> 
> bit instead now all lists require allocation of a list header - as opposed to 0
> bytes for an empty list (beyond the pointer to it). it also requires special
> treatment of the head as opposed to members.

There's no special case for head or tail nodes and even for empty
lists.  If you read through Ian's code (or mine), you'll see there
are *no* checks at all in the list operations.

To see why it works, a simple diagram would be very useful.
There was a good one in the Kernel Manual, but unfortunately
I can't find it online.


> you also miss the fact that initilising an empty list is
> more expensive and more work than simply starting with calloc()ed memory that's
> already NULL'ed out (so your lists start empty).

Initializing an empty list took just 3 m68k instructions, but I
agree with you that no initialization at all is even better.

 
> really - its neither one way or another. you pay the price somewhere in some
> way. either in code complexity, more setup complexity (and forgetting to set up
> your list and finding the bugs for that) etc. etc.

Agreed.  Failing to initialize a list head is a common
error which I've done several times.

-- 
  // Bernardo Innocenti - Develer S.r.l., R&D dept.
\X/  http://www.develer.com/




More information about the xorg mailing list