Hello Florian,
I've applied this patch in a local branch, and made various minor
tweaks.
I have one or two questions below.
On 5/3/19 5:01 AM, Florian Weimer wrote:
---
man3/tsearch.3 | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/man3/tsearch.3 b/man3/tsearch.3
index b64c9c6b7..c832b7009 100644
--- a/man3/tsearch.3
+++ b/man3/tsearch.3
@@ -40,6 +40,10 @@ tsearch, tfind, tdelete, twalk, tdestroy \- manage a binary search tree
.PP
.BI "void twalk(const void *" root ", void (*" action ")(const void *" nodep ,
.BI " VISIT " which ", int " depth "));"
+.PP
+.BI "void twalk_r(const void *" root ", void (*" action ")(const void *" np ,
+.BI " VISIT " which ", void *" closure "),
+.BI " void *" closure);"
.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
.B #include <search.h>
@@ -151,6 +155,16 @@ Thus, the choice of name
.B post\%order
is rather confusing.)
.PP
+.BR twalk_r ()
+is similar to
+.BR twalk (),
+but instead of the leval argument, the
Why is the 'level' argument deemed unnecessary for twalk_r()?
Is it worth adding some text to say why that argument is dropped?
Cheers,
Michael
+.I closure
+argument pointer is passed to each invocation of the action callback,
+unchanged. This pointer can be used to pass information to and from
+to the callback function in a thread-safe fashion, without resorting
+to global variables.
+.PP
.BR tdestroy ()
removes the whole tree pointed to by
.IR root ,
@@ -191,6 +205,9 @@ 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).
@@ -209,14 +226,19 @@ T{
.BR twalk ()
T} Thread safety MT-Safe race:root
T{
+.BR twalk_r ()
+T} Thread safety MT-Safe race:root
+T{
.BR tdestroy ()
T} Thread safety MT-Safe
.TE
.SH CONFORMING TO
POSIX.1-2001, POSIX.1-2008, SVr4.
-The function
+The functions
.BR tdestroy ()
-is a GNU extension.
+and
+.BR twalk_r ()
+are GNU extensions.
.SH NOTES
.BR twalk ()
takes a pointer to the root, while the other functions