summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/tsearch.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/stdlib/tsearch.3')
-rw-r--r--src/lib/libc/stdlib/tsearch.321
1 files changed, 14 insertions, 7 deletions
diff --git a/src/lib/libc/stdlib/tsearch.3 b/src/lib/libc/stdlib/tsearch.3
index cb8b050e7b..8456457e27 100644
--- a/src/lib/libc/stdlib/tsearch.3
+++ b/src/lib/libc/stdlib/tsearch.3
@@ -23,7 +23,7 @@
23.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 23.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25.\" 25.\"
26.\" $OpenBSD: tsearch.3,v 1.4 1999/05/10 17:56:28 aaron Exp $ 26.\" $OpenBSD: tsearch.3,v 1.5 1999/06/29 18:36:24 aaron Exp $
27.\" 27.\"
28.Dd June 15, 1997 28.Dd June 15, 1997
29.Dt TSEARCH 3 29.Dt TSEARCH 3
@@ -58,7 +58,8 @@ searches for the datum matched by the argument
58.Fa key 58.Fa key
59in the binary tree rooted at 59in the binary tree rooted at
60.Fa rootp , 60.Fa rootp ,
61returning a pointer to the datum if it is found and NULL 61returning a pointer to the datum if it is found and
62.Dv NULL
62if it is not. 63if it is not.
63.Pp 64.Pp
64.Fn tsearch 65.Fn tsearch
@@ -68,7 +69,7 @@ except that if no match is found,
68.Fa key 69.Fa key
69is inserted into the tree and a pointer to it is returned. If 70is inserted into the tree and a pointer to it is returned. If
70.Fa rootp 71.Fa rootp
71points to a NULL value a new binary search tree is created. 72points to a null value a new binary search tree is created.
72.Pp 73.Pp
73.Fn tdelete 74.Fn tdelete
74deletes a node from the specified binary search tree and returns 75deletes a node from the specified binary search tree and returns
@@ -89,7 +90,7 @@ and calls the function
89on each node. 90on each node.
90.Fa action 91.Fa action
91is called with three arguments: a pointer to the current node, 92is called with three arguments: a pointer to the current node,
92a value from the enum 93a value from the enum
93.Sy "typedef enum { preorder, postorder, endorder, leaf } VISIT;" 94.Sy "typedef enum { preorder, postorder, endorder, leaf } VISIT;"
94specifying the traversal type, and a node level (where level 95specifying the traversal type, and a node level (where level
95zero is the root of the tree). 96zero is the root of the tree).
@@ -99,16 +100,22 @@ zero is the root of the tree).
99.Sh RETURN VALUES 100.Sh RETURN VALUES
100The 101The
101.Fn tsearch 102.Fn tsearch
102function returns NULL if allocation of a new node fails (usually 103function returns
104.Dv NULL
105if allocation of a new node fails (usually
103due to a lack of free memory). 106due to a lack of free memory).
104.Pp 107.Pp
105.Fn tfind , 108.Fn tfind ,
106.Fn tsearch , 109.Fn tsearch ,
107and 110and
108.Fn tdelete 111.Fn tdelete
109return NULL if 112return
113.Dv NULL
114if
110.Fa rootp 115.Fa rootp
111is NULL or the datum cannot be found. 116is
117.Dv NULL
118or the datum cannot be found.
112.Pp 119.Pp
113The 120The
114.Fn twalk 121.Fn twalk