diff options
Diffstat (limited to 'man3/tsearch.3')
-rw-r--r-- | man3/tsearch.3 | 62 |
1 files changed, 42 insertions, 20 deletions
diff --git a/man3/tsearch.3 b/man3/tsearch.3 index 9b72c998c..ff2030276 100644 --- a/man3/tsearch.3 +++ b/man3/tsearch.3 @@ -3,7 +3,7 @@ .\" .\" SPDX-License-Identifier: Linux-man-pages-copyleft .\" -.TH tsearch 3 2023-01-26 "Linux man-pages 6.03" +.TH tsearch 3 2023-07-20 "Linux man-pages 6.05.01" .SH NAME tsearch, tfind, tdelete, twalk, twalk_r, tdestroy \- manage a binary search tree .SH LIBRARY @@ -192,44 +192,66 @@ also return NULL if .I rootp was NULL on entry. -.SH VERSIONS -.BR twalk_r () -is available since glibc 2.30. .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). -.ad l -.nh .TS allbox; lbx lb lb l l l. Interface Attribute Value T{ +.na +.nh .BR tsearch (), .BR tfind (), .BR tdelete () T} Thread safety MT-Safe race:rootp T{ +.na +.nh .BR twalk () T} Thread safety MT-Safe race:root T{ +.na +.nh .BR twalk_r () T} Thread safety MT-Safe race:root T{ +.na +.nh .BR tdestroy () T} Thread safety MT-Safe .TE -.hy -.ad .sp 1 .SH STANDARDS -POSIX.1-2001, POSIX.1-2008, SVr4. -The functions +.TP +.BR tsearch () +.TQ +.BR tfind () +.TQ +.BR tdelete () +.TQ +.BR twalk () +POSIX.1-2008. +.TP .BR tdestroy () -and +.TQ +.BR twalk_r () +GNU. +.SH HISTORY +.TP +.BR tsearch () +.TQ +.BR tfind () +.TQ +.BR tdelete () +.TQ +.BR twalk () +POSIX.1-2001, POSIX.1-2008, SVr4. +.TP .BR twalk_r () -are GNU extensions. +glibc 2.30. .SH NOTES .BR twalk () takes a pointer to the root, while the other functions @@ -260,21 +282,21 @@ in order. #include <stdio.h> #include <stdlib.h> #include <time.h> - +\& static void *root = NULL; - +\& static void * xmalloc(size_t n) { void *p; - +\& p = malloc(n); if (p) return p; fprintf(stderr, "insufficient memory\en"); exit(EXIT_FAILURE); } - +\& static int compare(const void *pa, const void *pb) { @@ -284,12 +306,12 @@ compare(const void *pa, const void *pb) return 1; return 0; } - +\& static void action(const void *nodep, VISIT which, int depth) { int *datap; - +\& switch (which) { case preorder: break; @@ -305,13 +327,13 @@ action(const void *nodep, VISIT which, int depth) break; } } - +\& int main(void) { int *ptr; int **val; - +\& srand(time(NULL)); for (unsigned int i = 0; i < 12; i++) { ptr = xmalloc(sizeof(*ptr)); |