Hacker News new | ask | show | jobs
by to3m 3224 days ago
The hcreate nonsense is POSIX, not C99, so a conforming C implementation might not include it.
2 comments

How does junk like this ever get into a standard? Didn't a whole committee of very experienced systems programmers have to sit down and say, "yes, these are routines that i think people will find generally useful"?

It looks like the same header, search.h, also includes functions for working with binary trees, where the user passes in the root pointer, and so which support multiple trees:

http://pubs.opengroup.org/onlinepubs/9699919799/functions/ts...

So this committee must have signed off on the hashtable stuff even though they had an example of how to do it properly right next to it!

A standards process is frequently about documenting what already exists in common implementations so that there is a specification for future implementations. POSIX was very much one of these processes.
OK... so how did junk like this ever get into enough implementations that people were forced to include it in the standard? ;)
tsearch/hsearch/lsearch have been around for at least 30 years. My guess is that they've been around for a lot longer.

Why not have these anyway? Otherwise people will make their own (probably buggy) equivalents.

I'm actually surprised that people aren't aware of them.

This is specifically about hcreate/hsearch, which are utterly useless, since you only get one hash table at a time. The reason you don't want crap like this is just that: it's crap.

The _r versions look perfectly sensible.

I was just thinking, "Where the hell did that come from?"

Signed,

POSIX_ME_HARDER