1 /* insque(3C) routines 2 This file is in the public domain. */ 3 4 /* 5 NAME 6 insque, remque -- insert, remove an element from a queue 7 8 SYNOPSIS 9 struct qelem { 10 struct qelem *q_forw; 11 struct qelem *q_back; 12 char q_data[]; 13 }; 14 15 void insque (struct qelem *elem, struct qelem *pred) 16 17 void remque (struct qelem *elem) 18 19 DESCRIPTION 20 Routines to manipulate queues built from doubly linked lists. 21 The insque routine inserts ELEM in the queue immediately after 22 PRED. The remque routine removes ELEM from its containing queue. 23 */ 24 25 26 struct qelem { 27 struct qelem *q_forw; 28 struct qelem *q_back; 29 }; 30 31 32 void insque(elem,pred)33insque (elem, pred) 34 struct qelem *elem; 35 struct qelem *pred; 36 { 37 elem -> q_forw = pred -> q_forw; 38 pred -> q_forw -> q_back = elem; 39 elem -> q_back = pred; 40 pred -> q_forw = elem; 41 } 42 43 44 void remque(elem)45remque (elem) 46 struct qelem *elem; 47 { 48 elem -> q_forw -> q_back = elem -> q_back; 49 elem -> q_back -> q_forw = elem -> q_forw; 50 } 51