2 Copyright © 1995-2016, The AROS Development Team. All rights reserved.
5 Desc: Initialize a list
10 /*****************************************************************************
13 #include <exec/lists.h>
21 Initialize a list. After that, you can use functions like
22 AddHead(), AddTail() and Insert() on the list.
25 list - the list to be initialized
31 You can also pass a struct MinList to this function.
39 NEWLIST() macro, exec.library/AddHead(), exec.library/AddTail(),
40 exec.library/Insert(), exec.library/Enqueue(),
41 exec.library/Remove(), exec.library/RemHead(), exec.library/RemTail()
45 ******************************************************************************/
51 int main (int argc
, char ** argv
)
61 /* Initializing the list */
64 /* Adding a node to the list */
65 AddHead (&list
, &node
);
68 But most of the time, you will do something like this: The struct
69 Usage contains a node as it's first field. Now you can collect any
70 number of struct Usage structures in a list.
72 AddTail (&list
, (struct Node
*)&usage
);
75 If you want to avoid the cast, you can of course do this:
77 AddTail (&list, &usage.node);
79 but sometimes you won't, because then you can write general
80 functions to handle lists with all kinds of nodes in them.