xref: /minix3/lib/libc/stdlib/remque.c (revision f14fb602092e015ff630df58e17c2a9cd57d29b3)
12fe8fb19SBen Gras /*
22fe8fb19SBen Gras  *  Copyright (c) 1993 John Brezak
32fe8fb19SBen Gras  *  All rights reserved.
42fe8fb19SBen Gras  *
52fe8fb19SBen Gras  *  Redistribution and use in source and binary forms, with or without
62fe8fb19SBen Gras  *  modification, are permitted provided that the following conditions
72fe8fb19SBen Gras  *  are met:
82fe8fb19SBen Gras  *  1. Redistributions of source code must retain the above copyright
92fe8fb19SBen Gras  *     notice, this list of conditions and the following disclaimer.
102fe8fb19SBen Gras  *  2. Redistributions in binary form must reproduce the above copyright
112fe8fb19SBen Gras  *     notice, this list of conditions and the following disclaimer in the
122fe8fb19SBen Gras  *     documentation and/or other materials provided with the distribution.
132fe8fb19SBen Gras  *  3. The name of the author may be used to endorse or promote products
142fe8fb19SBen Gras  *     derived from this software without specific prior written permission.
152fe8fb19SBen Gras  *
162fe8fb19SBen Gras  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
172fe8fb19SBen Gras  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
182fe8fb19SBen Gras  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
192fe8fb19SBen Gras  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
202fe8fb19SBen Gras  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
212fe8fb19SBen Gras  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
222fe8fb19SBen Gras  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
232fe8fb19SBen Gras  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
242fe8fb19SBen Gras  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
252fe8fb19SBen Gras  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
262fe8fb19SBen Gras  * POSSIBILITY OF SUCH DAMAGE.
272fe8fb19SBen Gras  */
282fe8fb19SBen Gras 
292fe8fb19SBen Gras #include <sys/cdefs.h>
302fe8fb19SBen Gras #if defined(LIBC_SCCS) && !defined(lint)
31*f14fb602SLionel Sambuc __RCSID("$NetBSD: remque.c,v 1.3 2012/06/25 22:32:45 abs Exp $");
322fe8fb19SBen Gras #endif /* LIBC_SCCS and not lint */
332fe8fb19SBen Gras 
342fe8fb19SBen Gras #include <assert.h>
352fe8fb19SBen Gras #include <search.h>
362fe8fb19SBen Gras 
372fe8fb19SBen Gras struct qelem {
382fe8fb19SBen Gras         struct qelem *q_forw;
392fe8fb19SBen Gras         struct qelem *q_back;
402fe8fb19SBen Gras };
412fe8fb19SBen Gras 
422fe8fb19SBen Gras void
remque(void * element)43*f14fb602SLionel Sambuc remque(void *element)
442fe8fb19SBen Gras {
452fe8fb19SBen Gras 	struct qelem *e = (struct qelem *) element;
462fe8fb19SBen Gras 
472fe8fb19SBen Gras 	_DIAGASSERT(e != 0);
482fe8fb19SBen Gras 
492fe8fb19SBen Gras 	if (e->q_forw)
502fe8fb19SBen Gras 		e->q_forw->q_back = e->q_back;
512fe8fb19SBen Gras 	if (e->q_back)
522fe8fb19SBen Gras 		e->q_back->q_forw = e->q_forw;
532fe8fb19SBen Gras }
54