From nobody Mon Jan 5 01:25:42 2026 X-Original-To: dev-commits-src-branches@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 4dkxSk4sQyz6N9Bd for ; Mon, 05 Jan 2026 01:25:42 +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 4dkxSk2Mksz3wyv for ; Mon, 05 Jan 2026 01:25:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767576342; 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=/u+nXjqJ5PnmxtqjjyQE+mN/YE6fxqoHipWyhgWiCM8=; b=uWbdpRV9xw55S3qIgOwZXvWYjM0n3Cb5p/KVXWtccJ4U3jmCFU9YzcARHsEGkBlZfPJBfk A1j37mj0qinqe6nbdyB7F8xnIfaonDMVODxu26iuRl9qa8vYHoQ6NfBTeS6N7fUnjLlAaT ahVhAtKXWAm4BuvJX57OnsEClMTcO/uxjNSz1RZmxNFZLOb7iEnBgf1CAXp+JPEThsEG9q NzWMVk5h+cm8mIjAd77mQJSwAx845DNCI6+jqTTSg5shKn7Rnb9ga6ODVPhVOvO8eDFInm cHzmIZRogTxuM0YoFgyc+lgLrgUEJQuq01sI1r4FFbWc2GsCBx04KGDYqbRZqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767576342; 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=/u+nXjqJ5PnmxtqjjyQE+mN/YE6fxqoHipWyhgWiCM8=; b=Nmx34QCin+jMLkLXVGB+g0+rVXZk64o5OXGGcHeQY31DsyHywoI519p8Aoi8BpsFJ7LBIG 4E89eOhlE/9Hpn3yzrKsohQhEKmVM5poQJVtfK4FqukL4+Hv/lusyoWx3v0juocP4FrRkY H/AnEtjY/26+Y/uOuUim6RZxETkZ1bpmw8xDL5ErSP+UlSEPfJdYpWF1v7Y28DRqDVzyag NDGisLDb7rr2CRglfj7PLuuWkTSbnORZzHY8lL0bvYSih9HLc8L1OEygp3oPSVzPos5rti Mq/QcQzIkfvBnWF7+7iNAHtv3HIa1HwLhdJ5UMNJXqLArGQlKUz637Y7DtPeug== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1767576342; a=rsa-sha256; cv=none; b=GcaO2ZfG0yaB86L5NYCgs1APq5MH9SBqG+eyhnS+veI8n8vy01EPqbcE/fYMOCljuzkwiL aRFie/MvSmsCZ+WtdS+WIZol4U9o8VzZbJzAyg2kP0wQ8+i2nzey/t8J4nyHpukGbOho+e itgk7UrKlLggOqzYbf1EJe/uYSZefiO3q5euYnIGHhgNFfT2KxwFtdk71rv7TnATBGW5pE RlPePeA/QP5ixFc/Ytq7N7uV0FRMPMCMpjgraKTOO1wWBTl1jXUR1B8T3EFvMAMdibRWcO eK4kCsro6nUHAclH/mz6nCInj9gqfPcMakq13bu5hoQXK9+UrPvNMBpqSt6B+Q== 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 4dkxSk1VjNz10QH for ; Mon, 05 Jan 2026 01:25:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3a31c by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 05 Jan 2026 01:25:42 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 8cbc9c011aef - stable/15 - tdestroy(3) man page List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/stable/15 X-Git-Reftype: branch X-Git-Commit: 8cbc9c011aef512d91c23c29f21c585d0823e883 Auto-Submitted: auto-generated Date: Mon, 05 Jan 2026 01:25:42 +0000 Message-Id: <695b1316.3a31c.6a1eb216@gitrepo.freebsd.org> The branch stable/15 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8cbc9c011aef512d91c23c29f21c585d0823e883 commit 8cbc9c011aef512d91c23c29f21c585d0823e883 Author: Konstantin Belousov AuthorDate: 2025-12-26 18:27:32 +0000 Commit: Konstantin Belousov CommitDate: 2026-01-05 00:44:21 +0000 tdestroy(3) man page (cherry picked from commit b0d4b059cf8425cbe094f93362a61c56a26d45f3) --- 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