* Rich Felker [2011-06-08 19:58:10 -0400]: > Moderate-effort new code: > - XSI search.h functionality i did this as it seems fairly simple/harmless unfortunately this api is quite useless in practice but i tried to write a simple and conformant implementation hsearch: i used open addressing hashtable (with doubling) (it is probably a bit bigger than a chained hash) i used a simple hash function (its output must be size_t so clever 32bit hash functions are not ok) standard is not clear if item.key==NULL is allowed to be put into the table (i assumed NULL is not allowed as it says strcmp is used on the key, so i mark empty entries with NULL key) standard is not clear if after an out of memory event should there be a usable state, so i made it to work (if an insert fails the table can still be searched) this api does not provide iterator, number of items cannot queried and only string keys with strcmp can be used insque,remque: doubly linked list management without type safety.. lsearch,lfind: complicated api that can be replaced by a for loop tsearch: i provided two different implementations: plain binary tree (as used in bsd) and a self balancing avl tree (glibc seems to use rb-tree) the first one is simple, but walking the tree may use large amount of memory (stack memory, as i used recursion there) the avl tree implementation uses recursive functions (max depth of an avl tree with 2^42 nodes is 60) implementing (and using) this api is a bit painful the functions return node pointers that the user cannot really use.. attached code is also available here temporarily: http://port70.net/~nsz/musl/search/