aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKit Dallege <xaum.io@gmail.com>2026-03-27 01:57:10 +0000
committerWarner Losh <imp@FreeBSD.org>2026-06-10 12:35:05 +0000
commitab8ceaaa86baa077fcdc020a0c05ccf88fcd54d1 (patch)
tree3aa03fe6ba2d1013bb3a6839c9921142acf82e2d
parent3a71a24bbeae3b72c91fd7c0b212ee607f18cba6 (diff)
hcreate(3): fix incorrect claim that hdestroy frees keys
The man page incorrectly stated that hdestroy() calls free(3) for each comparison key. The implementation (hdestroy_r.c) only frees the internal table structure, not the user-provided keys or data. This matches POSIX, which says hdestroy "shall dispose of the search table" without mentioning key deallocation. Update the description to clarify that the caller is responsible for freeing any memory associated with table entries. PR: 291240 Signed-off-by: Kit Dallege <xaum.io@gmail.com> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/2095
-rw-r--r--lib/libc/stdlib/hcreate.311
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/libc/stdlib/hcreate.3 b/lib/libc/stdlib/hcreate.3
index 4621850d4661..95a959fcedbb 100644
--- a/lib/libc/stdlib/hcreate.3
+++ b/lib/libc/stdlib/hcreate.3
@@ -26,7 +26,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd February 6, 2017
+.Dd June 9, 2026
.Dt HCREATE 3
.Os
.Sh NAME
@@ -86,10 +86,11 @@ After the call to
the data can no longer be considered accessible.
The
.Fn hdestroy
-function calls
-.Xr free 3
-for each comparison key in the search table
-but not the data item associated with the key.
+function disposes of the search table but does not free
+the comparison keys or data items stored in it.
+The caller is responsible for freeing any memory associated
+with table entries before calling
+.Fn hdestroy .
.Pp
The
.Fn hsearch