home *** CD-ROM | disk | FTP | other *** search
/ Graphics Programming Black Book (Special Edition) / BlackBook.bin / disk1 / source / chapter15 / l15-3.c < prev    next >
Text File  |  1997-06-18  |  776b  |  22 lines

  1. /* Deletes the node in the specified linked list that follows the
  2.    indicated node. List is headed by a head-of-list pointer; if the
  3.    pointer to the node to delete after points to the head-of-list
  4.    pointer, special handling is performed. */
  5.  
  6. #include "llist.h"
  7.  
  8. struct LinkNode *DeleteNodeAfter(struct LinkNode **HeadOfListPtr,
  9.    struct LinkNode *NodeToDeleteAfter)
  10. {
  11.    /* Handle specially if the node to delete after is actually the
  12.       head of the list (delete the first element in the list) */
  13.    if (NodeToDeleteAfter == (struct LinkNode *)HeadOfListPtr) {
  14.         *HeadOfListPtr = (*HeadOfListPtr)->NextNode;
  15.    } else {
  16.       NodeToDeleteAfter->NextNode =
  17.             NodeToDeleteAfter->NextNode->NextNode;
  18.    }
  19.    return(NodeToDeleteAfter);
  20. }
  21.  
  22.