standard library for hash table storage and hash algorithm

  • Thread starter Pieter Claassen
  • Start date
P

Pieter Claassen

Is there any reasonable standard hash table storage in C on Linux?

AFAICT the one in glibc has a data struct where the key and value pairs
both have to be null terminated pointers. In my case, that is fine for the
key, but I need to store a complex struct as the value and short of doing
dangerous things like printing the memory location of the value struct and
then recasting it when I want to get to the struct (which I think is
dangerous), I don't want to use non-standard libraries.

Also, what is a good way to generate a hash from a very large 96bit
identifier? the linux/hash.h only does longs which is a 32 bit number on
my machine.

Any help appreciated.

Thanks,
Pieter
 
C

CBFalconer

Pieter said:
Is there any reasonable standard hash table storage in C on Linux?

AFAICT the one in glibc has a data struct where the key and value
pairs both have to be null terminated pointers. In my case, that
is fine for the key, but I need to store a complex struct as the
value and short of doing dangerous things like printing the memory
location of the value struct and then recasting it when I want to
get to the struct (which I think is dangerous), I don't want to
use non-standard libraries.

Also, what is a good way to generate a hash from a very large
96 bit identifier? the linux/hash.h only does longs which is a
32 bit number on my machine.

In reverse order, maybe treat it as a 12 char string? Look up the
hash references in the following.

hashlib is completely standard portable C. Available under GPL
at:

<http://cbfalconer.home.att.net/download/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top