diff options
author | 2014-08-15 04:14:36 +0000 | |
---|---|---|
committer | 2014-08-15 04:14:36 +0000 | |
commit | b14f942ac6d84b4205b7a3031c1859c82ef887b7 (patch) | |
tree | 1ac5fb2dce5e1ec372096da9f1f1bbb2c7f95078 /lib/libc/stdlib/remque.c | |
parent | Use O_CLOEXEC wherever we open a file and then call fcntl(F_SETFD, FD_CLOEXEC) (diff) | |
download | wireguard-openbsd-b14f942ac6d84b4205b7a3031c1859c82ef887b7.tar.xz wireguard-openbsd-b14f942ac6d84b4205b7a3031c1859c82ef887b7.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 'lib/libc/stdlib/remque.c')
-rw-r--r-- | lib/libc/stdlib/remque.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/libc/stdlib/remque.c b/lib/libc/stdlib/remque.c index ae249ae0538..71b74b2dce0 100644 --- a/lib/libc/stdlib/remque.c +++ b/lib/libc/stdlib/remque.c @@ -1,4 +1,4 @@ -/* $OpenBSD: remque.c,v 1.2 2005/08/08 08:05:37 espie Exp $ */ +/* $OpenBSD: remque.c,v 1.3 2014/08/15 04:14:36 guenther Exp $ */ /* * Copyright (c) 1993 John Brezak @@ -28,6 +28,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include <stdlib.h> #include <search.h> struct qelem { @@ -38,7 +39,10 @@ struct qelem { void remque(void *element) { - struct qelem *e = (struct qelem *) element; - e->q_forw->q_back = e->q_back; - e->q_back->q_forw = e->q_forw; + struct qelem *e = element; + + if (e->q_forw != NULL) + e->q_forw->q_back = e->q_back; + if (e->q_back != NULL) + e->q_back->q_forw = e->q_forw; } |