Last change
on this file was 955, checked in by (none), 22 years ago |
This commit was manufactured by cvs2svn to create branch 'FREEBSD'.
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
|
File size:
990 bytes
|
Line | |
---|
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 | #include <sys/cdefs.h>
|
---|
10 | __FBSDID("$FreeBSD: src/lib/libc/stdlib/insque.c,v 1.3 2003/01/04 07:34:41 tjr Exp $");
|
---|
11 |
|
---|
12 | #define _SEARCH_PRIVATE
|
---|
13 | #include <search.h>
|
---|
14 | #ifdef DEBUG
|
---|
15 | #include <stdio.h>
|
---|
16 | #else
|
---|
17 | #include <stdlib.h> /* for NULL */
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | void
|
---|
21 | insque(void *element, void *pred)
|
---|
22 | {
|
---|
23 | struct que_elem *prev, *next, *elem;
|
---|
24 |
|
---|
25 | elem = (struct que_elem *)element;
|
---|
26 | prev = (struct que_elem *)pred;
|
---|
27 |
|
---|
28 | if (prev == NULL) {
|
---|
29 | elem->prev = elem->next = NULL;
|
---|
30 | return;
|
---|
31 | }
|
---|
32 |
|
---|
33 | next = prev->next;
|
---|
34 | if (next != NULL) {
|
---|
35 | #ifdef DEBUG
|
---|
36 | if (next->prev != prev) {
|
---|
37 | fprintf(stderr, "insque: Inconsistency detected:"
|
---|
38 | " next(%p)->prev(%p) != prev(%p)\n",
|
---|
39 | next, next->prev, prev);
|
---|
40 | }
|
---|
41 | #endif
|
---|
42 | next->prev = elem;
|
---|
43 | }
|
---|
44 | prev->next = elem;
|
---|
45 | elem->prev = prev;
|
---|
46 | elem->next = next;
|
---|
47 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.