LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-20-2009, 06:17 PM   #1
CoderMan
Member
 
Registered: Jan 2009
Location: Gemini Capsule 25164
Distribution: Gentoo
Posts: 375
Blog Entries: 24

Rep: Reputation: 43
libcmph


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. :]
 
Old 04-20-2009, 07:13 PM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
Originally Posted by CoderMan View Post
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.

Last edited by Hko; 04-20-2009 at 07:14 PM.
 
Old 07-22-2009, 04:32 PM   #3
kristopolous
LQ Newbie
 
Registered: Jun 2008
Posts: 1

Rep: Reputation: 0
CMPH is good

Glib is huge, obtuse, difficult to use, heavily abstracted, over-designed, and slow.

The site for the project is cmph.sourceforge.net

It's a wonderfully simple and functional tool.
 
Old 07-22-2009, 04:42 PM   #4
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

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.

IMHO .. PSM
 
Old 07-23-2009, 09:22 AM   #5
orgcandman
Member
 
Registered: May 2002
Location: new hampshire
Distribution: Fedora, RHEL
Posts: 600

Rep: Reputation: 110Reputation: 110
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.

-Aaron
 
Old 07-23-2009, 11:40 AM   #6
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
Originally Posted by orgcandman View Post
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 View Post
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 View Post
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.

Last edited by Hko; 07-23-2009 at 11:46 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration