Created attachment 265666 [details] Shell session: trivial example + valgrind The manpage claims that: > The hdestroy() function calls free(3) for each comparison key in > the search table but not the data item associated with the key. This seems incorrect. The implementation frees the table but not the table items: https://cgit.freebsd.org/src/tree/lib/libc/stdlib/hdestroy_r.c See also attached proof. I think the problem is in the manpage because current implementation behaves correctly: - POSIX is not specific about it in the function description, but it provides an example where the caller holds ownership of the keys: https://pubs.opengroup.org/onlinepubs/9699919799/functions/hcreate.html - The GNU manpage hsearch(3) claims that: "The hdestroy() and hdestroy_r() functions do not free the buffers pointed to by the key and data elements of the hash table entries".