insremque.c 1.6 KB

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