man rlist (Fonctions bibliothèques) - Roy doublely linked list implementation

NAME

rlist - Roy doublely linked list implementation

SYNOPSIS

#include <roy.h>

DESCRIPTION

The rlist code strings together list entries wihout having the over head of the extra pointer dereference. These list entries are defined and allocated by the user.

The User Defined Entry
In order to use these lists, you must create your own structure to be used as the entrys of the list. This structure *MUST* start with the first entry as 'RLIST_HEADER;'.
        struct FooEntry {
                RLIST_HEADER;
                char *foodata;
                /* ... */
        };
You can create the toplevel RList structure by using rlist_new(3) (free with rlist_free(3)), or you can allocate the list structure yourself, and call RLIST_INIT(list) on it. This initializes the list, setting up the tail and head pointers.
RLIST_INIT (list)
Initialize a newly created list structure. The 'list' argument needs to be an RList struct.
        {
                RList list;
                RLIST_INIT (&list);
                /* ... rlist functions ... */
        }
RLIST_DESTRUCT (list)
Set the head and tail pointers of the 'list' argument to point to NULL, effectivly destorying the list.
        {
                RList list;
                RLIST_INIT (&list);
                /* ... */
                RLIST_DESTRUCT (&list);
        }
RLIST_FOREACH (list, entry)
This macro walks through a list, assigning 'entry' to the list item through each iteration. The programmer can use CWbreak, CWcontinue, or CWgoto safely. All rlist functions except rlist_free(3) can be called safely inside the RLIST_FOREACH macro. Note that this includes rlist_remove(3) on the current item. Operations should not be performed on the next item in the list however, as a pointer is kept to that item through each iteration.
        RLIST_FOREACH (list, entry) {
                if (entry->foodata == NULL)
                        break;
                printf ("Data: %s.\n", entry->foodata);
        } RFOREACH_CLOSE;
RLIST_FOREACH_REVERSE (list, entry)
Same as RLIST_FOREACH, but start at the end of the list, and walk backwards.

SEE ALSO