>Reentrant versions have existed for quite some time.
Not in POSIX. glibc has one, but that doesn't do much good if you want your code to work portably. I do see they've made their way into Free and Net BSD, but not Open. Are they available for Mac? Any of the surviving commercial unixes?
>> having to know how big the table needs to be at initialization time with no automatic resizing
>The posted implementation resizes by creating an entirely new table and then moving all entries. The exact same mechanism is available with hsearch.
That's how resizing a hash table typically works, yes. Except it's normally done automatically and transparently by the hash table code. hsearch doesn't do that. And since it doesn't give you a way to iterate over values in the table, you'd have to keep a separate list of everything you add to it in order to manually delete the existing table and make a bigger one and re-add everything to it... Like I said, it's terrible.
>Reentrant versions have existed for quite some time.
Not in POSIX. glibc has one, but that doesn't do much good if you want your code to work portably. I do see they've made their way into Free and Net BSD, but not Open. Are they available for Mac? Any of the surviving commercial unixes?
>> having to know how big the table needs to be at initialization time with no automatic resizing
>The posted implementation resizes by creating an entirely new table and then moving all entries. The exact same mechanism is available with hsearch.
That's how resizing a hash table typically works, yes. Except it's normally done automatically and transparently by the hash table code. hsearch doesn't do that. And since it doesn't give you a way to iterate over values in the table, you'd have to keep a separate list of everything you add to it in order to manually delete the existing table and make a bigger one and re-add everything to it... Like I said, it's terrible.