git: b76b052a2d8f - main - tdelete(3): Document return value when deleting root node
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 26 Nov 2026 15:30:10 UTC
The branch main has been updated by obiwac:
URL: https://cgit.FreeBSD.org/src/commit/?id=b76b052a2d8f99e408beed89062bc9881ff0016c
commit b76b052a2d8f99e408beed89062bc9881ff0016c
Author: Aymeric Wibo <obiwac@FreeBSD.org>
AuthorDate: 2026-11-26 15:26:49 +0000
Commit: Aymeric Wibo <obiwac@FreeBSD.org>
CommitDate: 2026-11-26 15:27:00 +0000
tdelete(3): Document return value when deleting root node
tsearch.3 said that tdelete() returns a pointer to the parent of the
deleted node, but the root has no parent. In that case, tdelete()
returns an unspecified non-NULL pointer (currently (void *)1) which must
not be dereferenced. Document this.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D61969
---
lib/libc/stdlib/tsearch.3 | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/lib/libc/stdlib/tsearch.3 b/lib/libc/stdlib/tsearch.3
index 657acdfedf18..ab55c5191947 100644
--- a/lib/libc/stdlib/tsearch.3
+++ b/lib/libc/stdlib/tsearch.3
@@ -26,7 +26,7 @@
.\"
.\" OpenBSD: tsearch.3,v 1.2 1998/06/21 22:13:49 millert Exp
.\"
-.Dd November 17, 2026
+.Dd November 23, 2026
.Dt TSEARCH 3
.Os
.Sh NAME
@@ -107,7 +107,12 @@ and
.Fn tsearch .
If the node to be deleted is the root of the binary search tree,
.Fa rootp
-will be adjusted.
+will be adjusted,
+and, since it has no parent,
+.Fn tdelete
+returns an unspecified
+.Pf non- Dv NULL
+pointer which must not be dereferenced.
.Pp
The
.Fn tdestroy