diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libc/stdlib/tsearch.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/lib/libc/stdlib/tsearch.c b/src/lib/libc/stdlib/tsearch.c index 667c57731b..2f5e369f6a 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.6 2006/04/04 11:21:50 moritz Exp $ */ | 1 | /* $OpenBSD: tsearch.c,v 1.7 2012/02/06 20:29:54 guenther 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 |
| @@ -56,12 +56,12 @@ tdelete(const void *vkey, void **vrootp, | |||
| 56 | { | 56 | { |
| 57 | node **rootp = (node **)vrootp; | 57 | node **rootp = (node **)vrootp; |
| 58 | char *key = (char *)vkey; | 58 | char *key = (char *)vkey; |
| 59 | node *p; | 59 | node *p = (node *)1; |
| 60 | node *q; | 60 | node *q; |
| 61 | node *r; | 61 | node *r; |
| 62 | int cmp; | 62 | int cmp; |
| 63 | 63 | ||
| 64 | if (rootp == (struct node_t **)0 || (p = *rootp) == (struct node_t *)0) | 64 | if (rootp == (struct node_t **)0 || *rootp == (struct node_t *)0) |
| 65 | return ((struct node_t *)0); | 65 | return ((struct node_t *)0); |
| 66 | while ((cmp = (*compar)(key, (*rootp)->key)) != 0) { | 66 | while ((cmp = (*compar)(key, (*rootp)->key)) != 0) { |
| 67 | p = *rootp; | 67 | p = *rootp; |
| @@ -86,8 +86,6 @@ tdelete(const void *vkey, void **vrootp, | |||
| 86 | q->right = (*rootp)->right; | 86 | q->right = (*rootp)->right; |
| 87 | } | 87 | } |
| 88 | } | 88 | } |
| 89 | if (p == *rootp) | ||
| 90 | p = q; | ||
| 91 | free((struct node_t *) *rootp); /* D4: Free node */ | 89 | free((struct node_t *) *rootp); /* D4: Free node */ |
| 92 | *rootp = q; /* link parent to new node */ | 90 | *rootp = q; /* link parent to new node */ |
| 93 | return(p); | 91 | return(p); |
