scripts: prepare new configuration for x86_64 on vault13 server using pre build cross...
[AROS.git] / compiler / alib / newlist.c
blob72d8f2c25df3be91a8a065e81e32b704e58ae918
1 /*
2 Copyright © 1995-2016, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Initialize a list
6 Lang: english
7 */
10 /*****************************************************************************
12 NAME */
13 #include <exec/lists.h>
15 void NewList (
17 /* SYNOPSIS */
18 struct List * list)
20 /* FUNCTION
21 Initialize a list. After that, you can use functions like
22 AddHead(), AddTail() and Insert() on the list.
24 INPUTS
25 list - the list to be initialized
27 RESULT
28 None.
30 NOTES
31 You can also pass a struct MinList to this function.
33 EXAMPLE
34 See below.
36 BUGS
38 SEE ALSO
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()
43 INTERNALS
45 ******************************************************************************/
47 NEWLIST(list);
48 } /* NewList */
50 #ifdef TEST
51 int main (int argc, char ** argv)
53 struct List list;
54 struct Node node;
55 struct Usage
57 struct Node node;
58 int data;
59 } usage;
61 /* Initializing the list */
62 NewList (&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.
83 return 0;
84 } /* main */
85 #endif /* TEST */