]> git.karo-electronics.de Git - mdnsd.git/blob - xht.h
Applied Simons initial checkin, first slightly modifications
[mdnsd.git] / xht.h
1 #ifndef xht_h
2 #define xht_h
3
4 // simple string->void* hashtable, very static and bare minimal, but efficient
5
6 typedef struct xht_struct *xht;
7
8 // must pass a prime#
9 xht xht_new(int prime);
10
11 // caller responsible for key storage, no copies made (don't free it b4 xht_free()!)
12 // set val to NULL to clear an entry, memory is reused but never free'd (# of keys only grows to peak usage)
13 void xht_set(xht h, const char *key, void *val);
14
15 // ooh! unlike set where key/val is in caller's mem, here they are copied into xht and free'd when val is 0 or xht_free()
16 void xht_store(xht h, const char *key, int klen, void *val, int vlen);
17
18 // returns value of val if found, or NULL
19 void *xht_get(xht h, const char *key);
20
21 // free the hashtable and all entries
22 void xht_free(xht h);
23
24 // pass a function that is called for every key that has a value set
25 typedef void (*xht_walker)(xht h, const char *key, void *val, void *arg);
26 void xht_walk(xht h, xht_walker w, void *arg);
27
28 #endif
29