glib dependency for the X Server
Carsten Haitzler (The Rasterman)
raster at rasterman.com
Wed Apr 5 16:56:41 PDT 2006
On Wed, 05 Apr 2006 20:31:53 +0200 Bernardo Innocenti <bernie at develer.com>
babbled:
> 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.
aye - i think it's really a matter of preference. if you have a few very big
and heavily used lists then your way may be better, if you have 1000's of
smaller lists - the "glib way" is better as u avoid init/setup complexity/bugs.
last i checked i had a few hundred separate lists in my code so the "simple
init" has paid off - but it's a matter of deciding based on your expected usage
patterns :)
> --
> // Bernardo Innocenti - Develer S.r.l., R&D dept.
> \X/ http://www.develer.com/
>
--
------------- Codito, ergo sum - "I code, therefore I am" --------------
The Rasterman (Carsten Haitzler) raster at rasterman.com
裸好多
Tokyo, Japan (東京 日本)
More information about the xorg
mailing list