2 Copyright © 1995-2001, 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 ******************************************************************************/
53 // ASSERT_VALID_PTR(node); argh! TypeOfMem() doesn't know about the data segment!
54 ASSERT_VALID_PTR(list
);
57 Make the node point to the head of the list. Our predecessor is the
58 previous last node of the list.
60 node
->ln_Succ
= (struct Node
*)&list
->lh_Tail
;
61 node
->ln_Pred
= list
->lh_TailPred
;
64 Now we are the last now. Make the old last node point to us
65 and the pointer to the last node, too.
67 list
->lh_TailPred
->ln_Succ
= node
;
68 list
->lh_TailPred
= node
;