Add doubly linked lists
authorSøren Sandmann Pedersen <ssp@redhat.com>
Wed, 27 Apr 2011 16:07:16 +0000 (12:07 -0400)
committerSøren Sandmann Pedersen <ssp@redhat.com>
Sat, 2 Jun 2012 11:54:48 +0000 (07:54 -0400)
commita3ae88b71b9d2dfc53303963157ecce4b29f0486
tree8b6ee57e337e4bc1abceaad7a9b6aec4ba2e2923
parentc2230fe2aff709de21cc2ee3fa27c3f7578e7f9d
Add doubly linked lists

This commit adds some new inline functions to maintain a doubly linked
list.

The way to use them is to embed a pixman_link_t into the structures
that should be linked, and use a pixman_list_t as the head of the
list.

The new functions are

    pixman_list_init (pixman_list_t *list);
    pixman_list_prepend (pixman_list_t *list, pixman_link_t *link);
    pixman_list_move_to_front (pixman_list_t *list, pixman_link_t *link);

There are also a new macro:

    CONTAINER_OF(type, member, data);

that can be used to get from a pointer to a member to the containing
structure.

V2: Use the C89 macro offsetof() instead of rolling our own -
suggested by Alan Coopersmith.
pixman/pixman-compiler.h
pixman/pixman-private.h