2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Add a node at the end of a list.
8 #include <aros/debug.h>
9 #include <exec/lists.h>
10 #include <proto/exec.h>
12 /*****************************************************************************
16 AROS_LH2I(void, AddTail
,
19 AROS_LHA(struct List
*, list
, A0
),
20 AROS_LHA(struct Node
*, node
, A1
),
23 struct ExecBase
*, SysBase
, 41, Exec
)
26 Insert Node node at the end of a list.
29 list - The list to insert the node into
30 node - This node is to be inserted
40 // Insert Node at end of the list
49 ******************************************************************************/
52 // ASSERT_VALID_PTR(node); argh! TypeOfMem() doesn't know about the data segment!
53 ASSERT_VALID_PTR(list
);
56 Make the node point to the head of the list. Our predecessor is the
57 previous last node of the list.
59 node
->ln_Succ
= (struct Node
*)&list
->lh_Tail
;
60 node
->ln_Pred
= list
->lh_TailPred
;
63 Now we are the last now. Make the old last node point to us
64 and the pointer to the last node, too.
66 list
->lh_TailPred
->ln_Succ
= node
;
67 list
->lh_TailPred
= node
;