From nobody Mon Dec 29 17:19:17 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4dg2yF4V2Bz6M4Zl for ; Mon, 29 Dec 2025 17:19:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dg2yF2Wblz3CGf for ; Mon, 29 Dec 2025 17:19:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767028757; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nqOZDNPpSU/VpK88IKcaFCyPvBDnV2d10mty0ucfYlM=; b=YhQg4p16xwcS6G6ZNV2y2RyMci7NfVJP4Cl2Hf40xxNNSVf0VnvZcg5Fnb0GvSNQpWuLwI ze1+OIsDOPDPHr84MWbH6RXybIJ8dNiUdv1a8Wxth9OsxZGSAN2mSe7qqpFjEwgtqazTz5 Eo+JluYHIDm2PN8Kf/FmyJwgFWLLCSBfzYW+6QQMmHPiJzusf3OuJqVn/Uh0eVxrHOHlb8 4cmiDvvfcYAXmqFakYMIu2K/83BngK9zixIB4Awhv+h+El4p7FdEgERvqi7R/AyXa/KFg1 +b46JLOu7inci9fuHq6TC8y5dqcQoJKTpCUe5Y4fijG8XwqSRhLnkFUrsZxMLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767028757; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nqOZDNPpSU/VpK88IKcaFCyPvBDnV2d10mty0ucfYlM=; b=ROqKamEPEBChNzd6lry9exG4mS3scJMSYp2xrZE9rWsrGnJpqfCHPpE87pgO8ZJ/A+/QFl NGholKgYHCv8R25tlDpHWM/bWk5B8BPab4s6ywvzWRjSa9U896pz6ALZuSkWZ4dczxdTod +4elTot+e7rriraCUKwP7oT24KJ0fmoWX7OgROB7yGt7UOSTCm2o62iZFw3LtPccORb8m3 eavbdgiCY7VYRiFwx3LNKNUugX/B7jhXuoT2ulHGB53YIpdSgQTuhyQRRtnAvz+pOuDM1q 7VDnoS1cv5YrXwa/VX1OtTe/1DrknAvmqMzqAH4/5JPIPmZsGCA3KrP1FT3fFg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1767028757; a=rsa-sha256; cv=none; b=fcYFidg9zyN5Q1+mHS7UG7pY8QQSpEl2jzlx/arn5hCt0/sBQ8UTltBE6lmmwePOeMpR2T QbDttyHeS0kYbo4bRS+a6cx7IPXDQHbp9GmLk8Q7/aE/1WNMne7585wJgxjRNjuJbxFSwF tV0yYyB0yN/Q2MFP38yFnfYQuG+scqCnBrnEUX8qbOicpkeglbpN12UpgnLUHuT8XzbR5a vcXWpKfQXQKVXHvF2aX8NSuJpxppn/jB7yUxN/egpAtoGDALJI0A/NIR3WurFbtvejfux1 TaZmLPFu9SN3lPFbzJKQB+wZOstkLvG1OyJDEd7sppbAznPQ+UKHNV5BP5f/6g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dg2yF1vx7z7hS for ; Mon, 29 Dec 2025 17:19:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 2630f by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 29 Dec 2025 17:19:17 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: b0d4b059cf84 - main - tdestroy(3) man page List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b0d4b059cf8425cbe094f93362a61c56a26d45f3 Auto-Submitted: auto-generated Date: Mon, 29 Dec 2025 17:19:17 +0000 Message-Id: <6952b815.2630f.5f78ec2a@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b0d4b059cf8425cbe094f93362a61c56a26d45f3 commit b0d4b059cf8425cbe094f93362a61c56a26d45f3 Author: Konstantin Belousov AuthorDate: 2025-12-26 18:27:32 +0000 Commit: Konstantin Belousov CommitDate: 2025-12-29 17:18:55 +0000 tdestroy(3) man page Reviewed by: alc, emaste, ziaee Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D54365 --- lib/libc/stdlib/Makefile.inc | 3 ++- lib/libc/stdlib/tsearch.3 | 25 +++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/lib/libc/stdlib/Makefile.inc b/lib/libc/stdlib/Makefile.inc index e46a8d7340b2..c311ba3d2bcc 100644 --- a/lib/libc/stdlib/Makefile.inc +++ b/lib/libc/stdlib/Makefile.inc @@ -147,4 +147,5 @@ MLINKS+=strtoul.3 strtoull.3 \ strtoul.3 strtoumax.3 MLINKS+=tsearch.3 tdelete.3 \ tsearch.3 tfind.3 \ - tsearch.3 twalk.3 + tsearch.3 twalk.3 \ + tsearch.3 tdestroy.3 diff --git a/lib/libc/stdlib/tsearch.3 b/lib/libc/stdlib/tsearch.3 index edee01cafc52..f412c37a4ef0 100644 --- a/lib/libc/stdlib/tsearch.3 +++ b/lib/libc/stdlib/tsearch.3 @@ -36,6 +36,7 @@ .In search.h .Ft void * .Fn tdelete "const void * restrict key" "posix_tnode ** restrict rootp" "int (*compar) (const void *, const void *)" +.Fn tdestroy "posix_tnode *root" "(void (*node_free)(void *)" .Ft posix_tnode * .Fn tfind "const void *key" "posix_tnode * const *rootp" "int (*compar) (const void *, const void *)" .Ft posix_tnode * @@ -45,6 +46,7 @@ .Sh DESCRIPTION The .Fn tdelete , +.Fn tdestroy , .Fn tfind , .Fn tsearch , and @@ -95,6 +97,13 @@ If the node to be deleted is the root of the binary search tree, will be adjusted. .Pp The +.Fn tdestroy +function destroys the whole search tree, freeing all allocated nodes. +If tree keys need special handling on free, the +.Fa node_free +function can be provided, which is called on each key. +.Pp +The .Fn twalk function walks the binary search tree rooted in @@ -128,7 +137,9 @@ is NULL or the datum cannot be found. .Pp The .Fn twalk -function returns no value. +and +.Fn tdestroy +functions return no value. .Sh EXAMPLES This example uses .Fn tsearch @@ -184,6 +195,7 @@ main(void) tdelete(four, &root, comp); twalk(root, printwalk); + tdestroy(root, NULL); return 0; } .Ed @@ -192,8 +204,17 @@ main(void) .Xr hsearch 3 , .Xr lsearch 3 .Sh STANDARDS -These functions conform to +These +.Fn tdelete , +.Fn tfind , +.Fn tsearch , +and +.Fn twalk +functions conform to .St -p1003.1-2008 . +The +.Fn tdestroy +function is the glibc extension. .Pp The .Fa posix_tnode