5 * new_table_init creates a table with the specified
6 * number of buckets (size).
7 * obj_size is the size of individual objects (key+value),
8 * the first function is the hash function (called with the
9 * size and the payload pointer)
10 * the second function is the compare function, to tell if two
11 * objects are the same (XXX we could spare this if we also
12 * pass a key_size and use a bcmp for comparisons)
13 * Not extensible at the moment.
17 struct ipfw_ht* ipfw_ht_new(int size, int obj_size,
18 uint32_t (hash_fn)(const void *, uint32_t size),
19 int (cmp_fn)(const void*, const void*, int sz),
20 struct malloc_type *mtype);
21 void *ipfw_ht_destroy(struct ipfw_ht *h);
23 /* add a new object to the table, return success/failure */
24 int ipfw_ht_insert(struct ipfw_ht *h, const void *obj);
27 * returns a pointer to the matching object or NULL if not found.
30 const void *ipfw_ht_extract(struct ipfw_ht *h, const void *key);
32 /* remove an object from the table */
33 int ipfw_ht_remove(struct ipfw_ht *h, const void *key);
35 /* return the number of elements in the table */
36 int ipfw_ht_count(const struct ipfw_ht *h);
38 /* returns the first or next element. Works by hashing the
39 * current object and then finds the next one.
40 * If obj == NULL returns the first object in the table
42 const void *ipfw_ht_next(struct ipfw_ht *h, const void *obj);