summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/remque.c
diff options
context:
space:
mode:
authorguenther <>2014-08-15 04:14:36 +0000
committerguenther <>2014-08-15 04:14:36 +0000
commit3851718ce44d5d845cba0e7519642aa1c24624ca (patch)
treead98e89509d81894a7205c6b5bc0cb6747d59cd6 /src/lib/libc/stdlib/remque.c
parent1b0c3c7c757651ec07c6eba0d0be4a0966409111 (diff)
downloadopenbsd-3851718ce44d5d845cba0e7519642aa1c24624ca.tar.gz
openbsd-3851718ce44d5d845cba0e7519642aa1c24624ca.tar.bz2
openbsd-3851718ce44d5d845cba0e7519642aa1c24624ca.zip
XPG requires insque() and remque() to work with linear lists and not just
circular lists. Amazingly, they managed to extend the requirements to no longer match the behavior of the VAX instructions they were modeled after, so the trivial VAX ASM versions have to go. Nice job breaking it, X/Open! Based on a diff from enh (at) google.com ok miod@
Diffstat (limited to 'src/lib/libc/stdlib/remque.c')
-rw-r--r--src/lib/libc/stdlib/remque.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/lib/libc/stdlib/remque.c b/src/lib/libc/stdlib/remque.c
index ae249ae053..71b74b2dce 100644
--- a/src/lib/libc/stdlib/remque.c
+++ b/src/lib/libc/stdlib/remque.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: remque.c,v 1.2 2005/08/08 08:05:37 espie Exp $ */ 1/* $OpenBSD: remque.c,v 1.3 2014/08/15 04:14:36 guenther Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1993 John Brezak 4 * Copyright (c) 1993 John Brezak
@@ -28,6 +28,7 @@
28 * POSSIBILITY OF SUCH DAMAGE. 28 * POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31#include <stdlib.h>
31#include <search.h> 32#include <search.h>
32 33
33struct qelem { 34struct qelem {
@@ -38,7 +39,10 @@ struct qelem {
38void 39void
39remque(void *element) 40remque(void *element)
40{ 41{
41 struct qelem *e = (struct qelem *) element; 42 struct qelem *e = element;
42 e->q_forw->q_back = e->q_back; 43
43 e->q_back->q_forw = e->q_forw; 44 if (e->q_forw != NULL)
45 e->q_forw->q_back = e->q_back;
46 if (e->q_back != NULL)
47 e->q_back->q_forw = e->q_forw;
44} 48}