52#define GP_HTABLE_FOREACH(table, var) \
53 for (struct gp_htable_rec *var = (table)->recs; var < &((table)->recs[(table)->size]); var++) \
108 const char *str = key;
111 h = (h * 151 + *str++) % htable_size;
126 return !strcmp(key1, key2);
gp_htable * gp_htable_new(unsigned int order, int flags)
Allocates a hash table.
static size_t gp_htable_keys(gp_htable *self)
Returns the number of keys in hash table.
static size_t gp_htable_strhash(const void *key, size_t htable_size)
A string hashing function.
void * gp_htable_rem(gp_htable *self, const char *key)
Removes an entry from a hash table.
static int gp_htable_strcmp(const void *key1, const void *key2)
A string matching function.
void gp_htable_free(gp_htable *self)
Frees a hash table.
int gp_htable_init(gp_htable *self, unsigned int order, int flags)
Initializes an hash table embedded in a different structure.
gp_htable_flags
Flags to change how to deal with the hash table string keys.
void gp_htable_put(gp_htable *self, void *val, char *key)
Adds a pointer to a hash table.
void * gp_htable_get(gp_htable *self, const char *key)
Search for an element given a string key.
size_t used
Number of used slots in the hash table.
enum gp_htable_flags flags
Flags.
size_t size
Hash table record array size.
struct gp_htable_rec * recs
Array for the hash table records.