home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / tar-1.11.8-src.tgz / tar.out / fsf / tar / lib / insremque.c < prev    next >
C/C++ Source or Header  |  1996-09-28  |  1KB  |  55 lines

  1. /* Copyright (C) 1992 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. #ifdef HAVE_CONFIG_H
  20. # include <config.h>
  21. #endif
  22.  
  23. #include <stddef.h>
  24.  
  25. #include "insremque.h"
  26.  
  27. /* Insert ELEM into a doubly-linked list, after PREV.  */
  28.  
  29. void
  30. insque (elem, prev) 
  31.      struct qelem *elem;
  32.      struct qelem *prev;
  33. {
  34.   struct qelem *next = prev->q_forw;
  35.   prev->q_forw = elem;
  36.   if (next != NULL)
  37.     next->q_back = elem;
  38.   elem->q_forw = next;
  39.   elem->q_back = prev;
  40. }
  41.  
  42. /* Unlink ELEM from the doubly-linked list that it is in.  */
  43.  
  44. void
  45. remque (elem)
  46.      struct qelem *elem;
  47. {
  48.   struct qelem *next = elem->q_forw;
  49.   struct qelem *prev = elem->q_back;
  50.   if (next != NULL)
  51.     next->q_back = prev;
  52.   if (prev != NULL)
  53.     prev->q_forw = next;
  54. }
  55.