summaryrefslogtreecommitdiff
path: root/src/search/insque.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/search/insque.c')
-rw-r--r--src/search/insque.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/search/insque.c b/src/search/insque.c
new file mode 100644
index 00000000..b7475d84
--- /dev/null
+++ b/src/search/insque.c
@@ -0,0 +1,32 @@
+#include <search.h>
+
+struct node {
+ struct node *next;
+ struct node *prev;
+};
+
+void insque(void *element, void *pred)
+{
+ struct node *e = element;
+ struct node *p = pred;
+
+ if (!p) {
+ e->next = e->prev = 0;
+ return;
+ }
+ e->next = p->next;
+ e->prev = p;
+ p->next = e;
+ if (e->next)
+ e->next->prev = e;
+}
+
+void remque(void *element)
+{
+ struct node *e = element;
+
+ if (e->next)
+ e->next->prev = e->prev;
+ if (e->prev)
+ e->prev->next = e->next;
+}