This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/5223] tsearch returns node instead of key


https://sourceware.org/bugzilla/show_bug.cgi?id=5223

Alex Crivat <alex at crivat dot eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |alex at crivat dot eu

--- Comment #2 from Alex Crivat <alex at crivat dot eu> ---
(In reply to Andreas Schwab from comment #1)
> It returns a pointer to the element (node), not the key (which is the first 
> pointer in the node).

In this case shouldn't the documentation reflect this fact??

https://www.gnu.org/software/libc/manual/html_node/Tree-Search-Function.html
"The return value is a pointer to the matching element in the tree. If a new
element was created the pointer points to the new data (which is in fact key).
If an entry had to be created and the program ran out of space NULL is
returned."

If a new value is created tsearch returns a pointer to node_t which is a
structure internal to glibc. 
This is not a proper interface.
Cheers,
Alex

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]