Source

randomc / hash.h

#ifndef SOMEC_HASH_H
#define SOMEC_HASH_H

struct hash;
struct hash_list;

struct hash_list {
    char *key;
    void *value;
    struct hash_list *next;
};

struct hash {
    size_t size;
    struct hash_list **table;
};

unsigned int hash(struct hash *h, const char *str);
struct hash* hash_init();
void* hash_get(struct hash *h, const char *key, void *default_);
int hash_set(struct hash *h, const char *key, void *value);
void hash_free(struct hash *h);

#endif /* SOMEC_HASH_H */