glib dependency for the X Server

Ian Romanick idr at us.ibm.com
Mon Apr 3 08:33:34 PDT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Carsten Haitzler (The Rasterman) wrote:
> struct _XD_List /** A linked list node */
> {
>    void    *data; /**< Pointer to list element payload */
>    XD_List *next; /**< Next member in the list */
>    XD_List *prev; /**< Previous member in the list */
>    void    *accounting; /**< Private list accounting info - don't touch */
> };

What's disappointing here is that having the do NULL pointer checks on
list element pointers was solved 20 years ago on the Amiga.

See:

http://www.aros.org/documentation/developers/app-dev/exec-library.php#exec-lists

struct list {
    struct node * head;
    struct node * null;
    struct node * tail;
};

struct node {
    struct node * next;
    struct node * prev;
};

int is_list_empty( const struct list * l )
{
    /* Using (l->head == (struct node *) & l->null) also works.
     */
    return (l->head->next == NULL);
}

void list_init( struct list * l )
{
    l->head = (struct node *) & l->null;
    l->null = NULL;
    l->tail = (struct node *) & l->head;
}

void append_node( struct list * l, struct node * n )
{
    l->tail->next = n;
    n->next = (struct node *) & l->null;

    n->prev = l->tail;
    l->tail = n;
}

void remove_node( struct node * n )
{
    n->next->prev = n->prev;
    n->prev->next = n->next;
    n->next = NULL;
    n->prev = NULL;
}
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (GNU/Linux)

iD8DBQFEMUBOX1gOwKyEAw8RAtzWAJ9ViOy8dA7sCbjgpSps/el4roz6EwCgi62E
IotIYTeBlMqpBYiJTzB+Hzc=
=C9mz
-----END PGP SIGNATURE-----



More information about the xorg mailing list