3 ms·
linux.die.net man-pages are crap. See e.g. man7.org for better ones: https://man7.org/linux/man-pages/man3/tdelete.3.html https://man7.org/linux/man-pages/man3/
by zokier 6y ago
linux.die.net man-pages are crap. See e.g. man7.org for better ones: https://man7.org/linux/man-pages/man3/tdelete.3.html https://man7.org/linux/man-pages/man3/tdelete.3.html
See also POSIX spec here: https://pubs.opengroup.org/onlinepubs/9699919799/functions/tdelete.html https://pubs.opengroup.org/onlinepubs/9699919799/functions/t...
> The tdelete() function shall return a pointer to the parent of the deleted node, or an unspecified non-null pointer if the deleted node was the root node, or a null pointer if the node is not found.
Oh and here is Ubuntu man pages, seeing that they are online and all:
https://manpages.ubuntu.com/manpages/focal/en/man3/tdelete.3.html https://manpages.ubuntu.com/manpages/focal/en/man3/tdelete.3...
https://manpages.ubuntu.com/manpages/focal/en/man3/tdelete.3posix.html https://manpages.ubuntu.com/manpages/focal/en/man3/tdelete.3...
- cee-studio 6y agoThanks for pointing out the updated man page. This is much better. But the another question is how developers are supposed to know which node is the root node, which is supposed to be opaque.
- geophile 6y agoYou have to know the root of the tree to do anything: void *tsearch(const void *key, void **rootp, int (*compar)(const void *, const void *)); void *tfind(const void *key, void *const *rootp, int (*compar)(const void *, const void *)); ... rootp points to a variable which points to the root of the tree. You can't operate on a tree unless you have a pointer to it, i.e., it's root.