Commit Graph

7 Commits

Author SHA1 Message Date
Ed Schouten
4ef9bd22ed Improve typing of POSIX search tree functions.
Back in 2015 when I reimplemented these functions to use an AVL tree, I
was annoyed by the weakness of the typing of these functions. Both tree
nodes and keys are represented by 'void *', meaning that things like the
documentation for these functions are an absolute train wreck.

To make things worse, users of these functions need to cast the return
value of tfind()/tsearch() from 'void *' to 'type_of_key **' in order to
access the key. Technically speaking such casts violate aliasing rules.
I've observed actual breakages as a result of this by enabling features
like LTO.

I've filed a bug report at the Austin Group. Looking at the way the bug
got resolved, they made a pretty good step in the right direction. A new
type 'posix_tnode' has been added to correspond to tree nodes. It is
still defined as 'void' for source-level compatibility, but in the very
far future it could be replaced by a proper structure type containing a
key pointer.

MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D8205
2016-10-13 18:25:40 +00:00
Craig Rodrigues
f98e0c9dd8 Use ANSI C prototypes. Eliminates -Wold-style-definition warnings. 2015-09-20 20:24:28 +00:00
Tim J. Robbins
051900864f No need to include <assert.h> here. 2003-01-05 02:43:18 +00:00
Mike Barcroft
553c116dad Add missing const qualifier in tfind(). 2002-10-03 06:33:33 +00:00
David E. O'Brien
333fc21e3c Fix the style of the SCM ID's.
I believe have made all of libc .c's as consistent as possible.
2002-03-22 21:53:29 +00:00
David E. O'Brien
c05ac53b8b Remove __P() usage. 2002-03-21 22:49:10 +00:00
Alfred Perlstein
64566a3e2a bring in binary search tree code.
Obtained from: NetBSD
2000-07-01 06:55:11 +00:00