Implement a hash table

Viewed 19344

I'm trying to create an efficient look-up table in C.

I have an integer as a key and a variable length char* as the value.

I've looked at uthash, but this requires a fixed length char* value. If I make this a big number, then I'm using too much memory.

struct my_struct {
    int key;
    char value[10];             
    UT_hash_handle hh;
};

Has anyone got any pointers? Any insight greatly appreciated.


Thanks everyone for the answers. I've gone with uthash and defined my own custom struct to accommodate my data.

3 Answers
Related