home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / emacs-18.59-src.tgz / emacs-18.59-src.tar / fsf / emacs18 / oldXMenu / insque.c < prev    next >
C/C++ Source or Header  |  1996-09-28  |  925b  |  39 lines

  1. /* This file implements the insque and remque functions of BSD.
  2.    It is not compiled by default, because that change would be too risky
  3.    to install right now.  If you find that HAVE_X_MENU leads to linker errors
  4.    because these functions are undefined, then compile this file
  5.    and arrange to link it in.  */
  6.  
  7. struct qelem {
  8.   struct    qelem *q_forw;
  9.   struct    qelem *q_back;
  10.   char q_data[1];
  11. };
  12.  
  13. /* Insert ELEM into a doubly-linked list, after PREV.  */
  14.  
  15. void
  16. insque (elem, prev) 
  17.      struct qelem *elem, *prev;
  18. {
  19.   struct qelem *next = prev->q_forw;
  20.   prev->q_forw = elem;
  21.   if (next)
  22.     next->q_back = elem;
  23.   elem->q_forw = next;
  24.   elem->q_back = prev;
  25. }
  26.  
  27. /* Unlink ELEM from the doubly-linked list that it is in.  */
  28.  
  29. remque (elem)
  30.      struct qelem *elem;
  31. {
  32.   struct qelem *next = elem->q_forw;
  33.   struct qelem *prev = elem->q_back;
  34.   if (next)
  35.     next->q_back = prev;
  36.   if (prev)
  37.     prev->q_forw = next;
  38. }
  39.