home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 2 / DATAFILE_PDCD2.iso / utilities2 / desklib / Libraries / LinkList / c / InsertA < prev    next >
Encoding:
Text File  |  1992-03-26  |  1.3 KB  |  42 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.InsertA.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_InsertAfter(linklist_header *anchor,
  24.                                  linklist_header *pos,
  25.                                  linklist_header *item)
  26. {
  27.   linklist_header *oldnext;
  28.  
  29.   oldnext = pos->next;
  30.  
  31.   if (oldnext == NULL)                             /* Insert at tail of list */
  32.     LinkList_AddToTail(anchor, item);
  33.   else
  34.   {
  35.     oldnext->previous = item;                      /* Link to next in list   */
  36.     item->next        = oldnext;
  37.  
  38.     pos->next         = item;                      /* Link "pos" in as prev  */
  39.     item->previous    = pos;
  40.   }
  41. }
  42.