home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / rom / exec / addhead.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-09  |  1.6 KB  |  79 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: addhead.c,v 1.10 1997/01/01 03:46:03 ldp Exp $
  4.  
  5.     Desc: Exec function AddHead()
  6.     Lang: english
  7. */
  8. #include "exec_intern.h"
  9. #include <exec/lists.h>
  10. #include <proto/exec.h>
  11.  
  12. /*****************************************************************************
  13.  
  14.     NAME */
  15.  
  16.     AROS_LH2I(void, AddHead,
  17.  
  18. /*  SYNOPSIS */
  19.     AROS_LHA(struct List *, list, A0),
  20.     AROS_LHA(struct Node *, node, A1),
  21.  
  22. /*  LOCATION */
  23.     struct ExecBase *, SysBase, 40, Exec)
  24.  
  25. /*  FUNCTION
  26.     Insert Node node as the first node of the list.
  27.  
  28.     INPUTS
  29.     list - The list to insert the node into
  30.     node - This node is to be inserted
  31.  
  32.     RESULT
  33.     None.
  34.  
  35.     NOTES
  36.  
  37.     EXAMPLE
  38.     struct List * list;
  39.     struct Node * pred;
  40.  
  41.     // Insert Node at top
  42.     AddHead (list, node);
  43.  
  44.     BUGS
  45.  
  46.     SEE ALSO
  47.     NewList(), AddTail(), Insert(), Remove(), RemHead(), RemTail(),
  48.     Enqueue()
  49.  
  50.     INTERNALS
  51.  
  52.     HISTORY
  53.     26-08-95    digulla created after EXEC-Routine
  54.     26-10-95    digulla adjusted to new calling scheme
  55.  
  56. ******************************************************************************/
  57. {
  58.     AROS_LIBFUNC_INIT
  59.     assert (node);
  60.     assert (list);
  61.  
  62.     /*
  63.     Make the node point to the old first node in the list and to the
  64.     head of the list.
  65.     */
  66.     node->ln_Succ       = list->lh_Head;
  67.     node->ln_Pred       = (struct Node *)&list->lh_Head;
  68.  
  69.     /*
  70.     New we come before the old first node which must now point to us
  71.     and the same applies to the pointer to-the-first-node in the
  72.     head of the list.
  73.     */
  74.     list->lh_Head->ln_Pred = node;
  75.     list->lh_Head       = node;
  76.     AROS_LIBFUNC_EXIT
  77. } /* AddHead */
  78.  
  79.