diff options
author | pat <> | 2005-03-30 18:51:49 +0000 |
---|---|---|
committer | pat <> | 2005-03-30 18:51:49 +0000 |
commit | 894b6ab0099e7d9ca2ad9acb75246cd0a4542167 (patch) | |
tree | f9fb8e9324f6cbdc10d72cab8b889d470252465a /src/lib/libc/stdlib/tsearch.c | |
parent | 162f8b042bf31ab94714a6f194e9836c08c085f5 (diff) | |
download | openbsd-894b6ab0099e7d9ca2ad9acb75246cd0a4542167.tar.gz openbsd-894b6ab0099e7d9ca2ad9acb75246cd0a4542167.tar.bz2 openbsd-894b6ab0099e7d9ca2ad9acb75246cd0a4542167.zip |
ansi + de-register
ok otto deraadt
Diffstat (limited to 'src/lib/libc/stdlib/tsearch.c')
-rw-r--r-- | src/lib/libc/stdlib/tsearch.c | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/src/lib/libc/stdlib/tsearch.c b/src/lib/libc/stdlib/tsearch.c index 67388b4e7f..a5d0c2b9b3 100644 --- a/src/lib/libc/stdlib/tsearch.c +++ b/src/lib/libc/stdlib/tsearch.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tsearch.c,v 1.4 2004/10/01 04:08:45 jsg Exp $ */ | 1 | /* $OpenBSD: tsearch.c,v 1.5 2005/03/30 18:51:49 pat Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Tree search generalized from Knuth (6.2.2) Algorithm T just like | 4 | * Tree search generalized from Knuth (6.2.2) Algorithm T just like |
@@ -22,12 +22,10 @@ typedef struct node_t { | |||
22 | 22 | ||
23 | /* find or insert datum into search tree */ | 23 | /* find or insert datum into search tree */ |
24 | void * | 24 | void * |
25 | tsearch(vkey, vrootp, compar) | 25 | tsearch(const void *vkey, void **vrootp, |
26 | const void *vkey; /* key to be located */ | 26 | int (*compar)(const void *, const void *)) |
27 | void **vrootp; /* address of tree root */ | ||
28 | int (*compar)(const void *, const void *); | ||
29 | { | 27 | { |
30 | register node *q; | 28 | node *q; |
31 | char *key = (char *)vkey; | 29 | char *key = (char *)vkey; |
32 | node **rootp = (node **)vrootp; | 30 | node **rootp = (node **)vrootp; |
33 | 31 | ||
@@ -53,16 +51,14 @@ tsearch(vkey, vrootp, compar) | |||
53 | 51 | ||
54 | /* delete node with given key */ | 52 | /* delete node with given key */ |
55 | void * | 53 | void * |
56 | tdelete(vkey, vrootp, compar) | 54 | tdelete(const void *vkey, void **vrootp, |
57 | const void *vkey; /* key to be deleted */ | 55 | int (*compar)(const void *, const void *)) |
58 | void **vrootp; /* address of the root of tree */ | ||
59 | int (*compar)(const void *, const void *); | ||
60 | { | 56 | { |
61 | node **rootp = (node **)vrootp; | 57 | node **rootp = (node **)vrootp; |
62 | char *key = (char *)vkey; | 58 | char *key = (char *)vkey; |
63 | node *p; | 59 | node *p; |
64 | register node *q; | 60 | node *q; |
65 | register node *r; | 61 | node *r; |
66 | int cmp; | 62 | int cmp; |
67 | 63 | ||
68 | if (rootp == (struct node_t **)0 || (p = *rootp) == (struct node_t *)0) | 64 | if (rootp == (struct node_t **)0 || (p = *rootp) == (struct node_t *)0) |
@@ -97,10 +93,7 @@ tdelete(vkey, vrootp, compar) | |||
97 | 93 | ||
98 | /* Walk the nodes of a tree */ | 94 | /* Walk the nodes of a tree */ |
99 | static void | 95 | static void |
100 | trecurse(root, action, level) | 96 | trecurse(node *root, void (*action)(const void *, VISIT, int), int level) |
101 | register node *root; /* Root of the tree to be walked */ | ||
102 | register void (*action)(); /* Function to be called at each node */ | ||
103 | register int level; | ||
104 | { | 97 | { |
105 | if (root->left == (struct node_t *)0 && root->right == (struct node_t *)0) | 98 | if (root->left == (struct node_t *)0 && root->right == (struct node_t *)0) |
106 | (*action)(root, leaf, level); | 99 | (*action)(root, leaf, level); |
@@ -117,12 +110,10 @@ trecurse(root, action, level) | |||
117 | 110 | ||
118 | /* Walk the nodes of a tree */ | 111 | /* Walk the nodes of a tree */ |
119 | void | 112 | void |
120 | twalk(vroot, action) | 113 | twalk(const void *vroot, void (*action)(const void *, VISIT, int)) |
121 | const void *vroot; /* Root of the tree to be walked */ | ||
122 | void (*action)(const void *, VISIT, int); | ||
123 | { | 114 | { |
124 | node *root = (node *)vroot; | 115 | node *root = (node *)vroot; |
125 | 116 | ||
126 | if (root != (node *)0 && action != (void(*)())0) | 117 | if (root != (node *)0 && action != (void (*)(const void *, VISIT, int))0) |
127 | trecurse(root, action, 0); | 118 | trecurse(root, action, 0); |
128 | } | 119 | } |