Updated PCI IDs to latest snapshot.
[tangerine.git] / compiler / alib / newlist.c
blob0ff0bef8a63cd62fec0e8f8a72b8579d4ed81dad
1 /*
2 Copyright © 1995-2001, 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 HISTORY
46 28.11.96 digulla written
48 ******************************************************************************/
50 NEWLIST(list);
51 } /* NewList */
53 #ifdef TEST
54 #include <stdio.h>
56 int main (int argc, char ** argv)
58 struct List list;
59 struct Node node;
60 struct Usage
62 struct Node node;
63 int data;
64 } usage;
66 /* Initializing the list */
67 NewList (&list);
69 /* Adding a node to the list */
70 AddHead (&list, &node);
73 But most of the time, you will do something like this: The struct
74 Usage contains a node as it's first field. Now you can collect any
75 number of struct Usage structures in a list.
77 AddTail (&list, (struct Node *)&usage);
80 If you want to avoid the cast, you can of course do this:
82 AddTail (&list, &usage.node);
84 but sometimes you won't, because then you can write general
85 functions to handle lists with all kinds of nodes in them.
88 return 0;
89 } /* main */
90 #endif /* TEST */