I had the same need and did some research and ended up using libcfu
It is simple and straightforward, so if I need to change, I can do it without spending too much time to understand. It is also a BSD license. No need to change my structures (to insert the words of the next pointer)
I had to decline other options for the following reasons (my personal reasons, YMMV):
- sglib β this is a macro labyrinth, and it was inconvenient for me to debug / make changes on such a code base, using only macros
- cbfalconer β a lot of licensed red flags, and the site was omitted and too many adverse discussions on the Internet about support / author; did not want to take risks
- google sparce-hash β as already said, this is for C ++, not C
- glib (gnome hash) β looked very promising; but I could not find an easy way to install the developer kit; I just needed C routines / files - not a complete bloated development environment
- Judy β seems too complicated for simple use .. also was not ready to debug myself if I had to face any problems.
- npsml (mentioned here) -> cannot find source
- strmap is found very simple and useful - just too simple that both the key and value must be strings; String value is too strict (should take void *)
- uthash β seems good (mentioned on a hash table on wikipedia); found that he requires that the structure be modified - did not want to do this, since performace is not really a problem for my use - it is a high development speed.
In conclusion, for a very simple use, strmap is good; uthash if you are interested in using extra memory. If only development speed or ease of use is the primary goal, libcfu wins [note libcfu internally allocates memory to support nodes / hash tables]. Surprisingly, there are not many simple C hash code implementations.
Karthik Gurusamy Dec 12 2018-11-12T00: 00Z
source share