home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 2 / DATAFILE_PDCD2.iso / utilities2 / desklib / Libraries / LinkList / c / Unlink < prev   
Encoding:
Text File  |  1992-03-26  |  1.4 KB  |  43 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.Unlink.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_Unlink(linklist_header *anchor, linklist_header *item)
  24. {
  25.   linklist_header *prev, *next;
  26.  
  27.   next = item->next;
  28.   prev = item->previous;
  29.  
  30.   if (next == NULL)  
  31.     anchor->previous = prev;                            /* was last in list  */
  32.   else
  33.     next->previous   = prev;                            /* was in middle     */
  34.  
  35.   if (prev == NULL)
  36.     anchor->next = next;                                /* was first in list */
  37.   else
  38.     prev->next   = next;                                /* was in middle     */
  39.  
  40.   item->next     = NULL;                                /* kill to be safe   */
  41.   item->previous = NULL;
  42. }
  43.