1/* 2 * Initial implementation: 3 * Copyright (c) 2002 Robert Drehmel 4 * All rights reserved. 5 * 6 * As long as the above copyright statement and this notice remain 7 * unchanged, you can do what ever you want with this file. 8 */ 9#define _SEARCH_PRIVATE 10#include <search.h> 11#ifdef DEBUG 12#include <stdio.h> 13#else 14#include <stdlib.h> /* for NULL */ 15#endif 16 17void 18insque(void *element, void *pred) 19{ 20 struct que_elem *prev, *next, *elem; 21 22 elem = (struct que_elem *)element; 23 prev = (struct que_elem *)pred; 24 25 if (prev == NULL) { 26 elem->prev = elem->next = NULL; 27 return; 28 } 29 30 next = prev->next; 31 if (next != NULL) { 32#ifdef DEBUG 33 if (next->prev != prev) { 34 fprintf(stderr, "insque: Inconsistency detected:" 35 " next(%p)->prev(%p) != prev(%p)\n", 36 next, next->prev, prev); 37 } 38#endif 39 next->prev = elem; 40 } 41 prev->next = elem; 42 elem->prev = prev; 43 elem->next = next; 44} 45