ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi. I'm looking for an open-source, thread-safe, simple to use lib for using hash tables in my C app. libcmph seems to be what I'm looking for, but was hoping for feed back on a few questions:
1. Are libcmph functions thread-safe? The README file didn't explicitly say so...
2. Is any one else a little confused about the licensing? README says LGPL, COPYING says MPL, website says dual-license. So does that mean you just use whichever one you want?
3. I'm open to better suggestions for a hashing table library. Ideals are: simple to use, open source, thread-safe, and must be in Debian Lenny repository. :]
I'm open to better suggestions for a hashing table library. Ideals are: simple to use, open source, thread-safe, and must be in Debian Lenny repository. :]
I never used it myself, but the Glib library may be what you're looking for. It is used by many (all?) Gnome and GTK apps, so widely available and already loaded in RAM on quite a few systems. And clearly licensed by the LGPL.
I'm not sure if it is thread safe though. But I suppose that will be documented.
For coding against Glib, you will probably also want to install the "libglib2.0-dev" and "libglib2.0-doc" packages on your own system.
Without getting into the merits of cmph, let me emphasize that Hko is absolutely correct.
GLib can be an excellent solution for many different problems (including, perhaps, this one). And since GLib is so widely used, the base runtime is already likely to be loaded on most desktops, making the overhead essentially "zero" for any new app that wants to use Glib.
I'm going to come to CoderMan's defense here. We don't know what the software in question is meant to perform, where it is meant to be run, or what constraints it has. Suggesting to use a different library doesn't seem to answer the question, merely blow past it. Further, if he's not using this software on a machine that even has glib installed (such as a university server, or home file-serving machine) then he'll have to install glib, and all of glib's dependancies.
CoderMan:
Simply grep the source for things which are known to be posix-compliant thread-safe keywords. IE:
REENTRANT
pthread_mutex
_r(
the list goes on. If all else fails, you can really familiarize yourself with it and RTFS. If that still doesn't give any indication that it is threadsafe, you should assume that it isn't and use posix locks before and after your calls to the library.
We don't know what the software in question is meant to perform, where it is meant to be run, or what constraints it has.
If there are special requirements or circumstances, the OP should have mentioned that IMHO. As you said: we don't know...
Quote:
Originally Posted by orgcandman
Suggesting to use a different library doesn't seem to answer the question, merely blow past it.
I don't agree in this case. Please re-read the OP's point (3).
Quote:
Originally Posted by orgcandman
Further, if he's not using this software on a machine that even has glib installed (such as a university server, or home file-serving machine) then he'll have to install glib, and all of glib's dependancies.
That is very true of course. But the dependencies for glib are not that much: on ubuntu: libc6, libpcre3, libselinux1. And I guess you could get rid of selinux if you compile it yourself.
Also, I now noted that, CMPH does perfect hashes only. This means it is not not very suited to do not-so-dynamic hash tables, i.e. very good for "read often, but write/modify sparsely". The reason is perfect hashes need to be recalculated every time the hash-tables is modified. But for reading it is much more efficient than non-perfect hashes. CMPH is more specialized for a lot of look-ups on the hash table, containing a lot of entries. Glib's hash table is more general purpose.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.