home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 2 / DATAFILE_PDCD2.iso / utilities2 / desklib / Libraries / LinkList / c / AddToTail < prev    next >
Encoding:
Text File  |  1992-03-26  |  1.3 KB  |  37 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    LinkList.AddToTail.c
  12.     Author:  Copyright © 1992 Jason Williams
  13.     Version: 1.02 (16 Mar 1992)
  14.     Purpose: Linked list handling functions
  15. */
  16.  
  17.  
  18. #include "LinkList.h"
  19. #include <stdlib.h>
  20. #include <stdio.h>
  21.  
  22.  
  23. extern void LinkList_AddToTail(linklist_header *anchor, linklist_header *item)
  24. {
  25.   linklist_header *oldlast;
  26.  
  27.   oldlast          = anchor->previous;
  28.   item->next       = NULL;                           /* This item is last    */
  29.   item->previous   = oldlast;                        /* Link to end          */
  30.  
  31.   if (oldlast == NULL)
  32.     anchor->next = item;                  /* First item, so it is 1st & last */
  33.   else
  34.     oldlast->next = item;                            /* link to previous     */
  35.   anchor->previous = item;                           /* And link to header   */
  36. }
  37.