diff options
Diffstat (limited to 'src/lib/libc')
| -rw-r--r-- | src/lib/libc/stdlib/tsearch.3 | 4 | ||||
| -rw-r--r-- | src/lib/libc/stdlib/tsearch.c | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/libc/stdlib/tsearch.3 b/src/lib/libc/stdlib/tsearch.3 index 589f0574a8..ebc521ba17 100644 --- a/src/lib/libc/stdlib/tsearch.3 +++ b/src/lib/libc/stdlib/tsearch.3 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | .\" $OpenBSD: tsearch.3,v 1.13 2006/01/30 19:50:41 jmc Exp $ | 1 | .\" $OpenBSD: tsearch.3,v 1.14 2006/04/04 11:21:50 moritz Exp $ |
| 2 | .\" | 2 | .\" |
| 3 | .\" Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com> | 3 | .\" Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com> |
| 4 | .\" | 4 | .\" |
| @@ -74,7 +74,7 @@ and | |||
| 74 | .Fn tsearch . | 74 | .Fn tsearch . |
| 75 | If the node to be deleted is the root of the binary search tree, | 75 | If the node to be deleted is the root of the binary search tree, |
| 76 | .Fa rootp | 76 | .Fa rootp |
| 77 | will be adjusted. | 77 | will be adjusted and a pointer to the new root will be returned. |
| 78 | .Pp | 78 | .Pp |
| 79 | .Fn twalk | 79 | .Fn twalk |
| 80 | walks the binary search tree rooted in | 80 | walks the binary search tree rooted in |
diff --git a/src/lib/libc/stdlib/tsearch.c b/src/lib/libc/stdlib/tsearch.c index a5d0c2b9b3..667c57731b 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.5 2005/03/30 18:51:49 pat Exp $ */ | 1 | /* $OpenBSD: tsearch.c,v 1.6 2006/04/04 11:21:50 moritz 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 |
| @@ -86,6 +86,8 @@ 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; | ||
| 89 | free((struct node_t *) *rootp); /* D4: Free node */ | 91 | free((struct node_t *) *rootp); /* D4: Free node */ |
| 90 | *rootp = q; /* link parent to new node */ | 92 | *rootp = q; /* link parent to new node */ |
| 91 | return(p); | 93 | return(p); |
