xref: /openbsd-src/lib/libc/stdlib/remque.c (revision b14f942ac6d84b4205b7a3031c1859c82ef887b7)
1*b14f942aSguenther /*	$OpenBSD: remque.c,v 1.3 2014/08/15 04:14:36 guenther Exp $	*/
2cd087ff3Smillert 
3cd087ff3Smillert /*
4cd087ff3Smillert  *  Copyright (c) 1993 John Brezak
5cd087ff3Smillert  *  All rights reserved.
6cd087ff3Smillert  *
7cd087ff3Smillert  *  Redistribution and use in source and binary forms, with or without
8cd087ff3Smillert  *  modification, are permitted provided that the following conditions
9cd087ff3Smillert  *  are met:
10cd087ff3Smillert  *  1. Redistributions of source code must retain the above copyright
11cd087ff3Smillert  *     notice, this list of conditions and the following disclaimer.
12cd087ff3Smillert  *  2. Redistributions in binary form must reproduce the above copyright
13cd087ff3Smillert  *     notice, this list of conditions and the following disclaimer in the
14cd087ff3Smillert  *     documentation and/or other materials provided with the distribution.
15cd087ff3Smillert  *  3. The name of the author may be used to endorse or promote products
16cd087ff3Smillert  *     derived from this software without specific prior written permission.
17cd087ff3Smillert  *
18cd087ff3Smillert  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
19cd087ff3Smillert  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20cd087ff3Smillert  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21cd087ff3Smillert  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
22cd087ff3Smillert  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23cd087ff3Smillert  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24cd087ff3Smillert  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25cd087ff3Smillert  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26cd087ff3Smillert  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27cd087ff3Smillert  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28cd087ff3Smillert  * POSSIBILITY OF SUCH DAMAGE.
29cd087ff3Smillert  */
30cd087ff3Smillert 
31*b14f942aSguenther #include <stdlib.h>
32cd087ff3Smillert #include <search.h>
33cd087ff3Smillert 
34cd087ff3Smillert struct qelem {
35cd087ff3Smillert         struct qelem *q_forw;
36cd087ff3Smillert         struct qelem *q_back;
37cd087ff3Smillert };
38cd087ff3Smillert 
39cd087ff3Smillert void
remque(void * element)40cd087ff3Smillert remque(void *element)
41cd087ff3Smillert {
42*b14f942aSguenther 	struct qelem *e = element;
43*b14f942aSguenther 
44*b14f942aSguenther 	if (e->q_forw != NULL)
45cd087ff3Smillert 		e->q_forw->q_back = e->q_back;
46*b14f942aSguenther 	if (e->q_back != NULL)
47cd087ff3Smillert 		e->q_back->q_forw = e->q_forw;
48cd087ff3Smillert }
49