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