32 const unsigned char *name = (
const unsigned char *)s;
33 unsigned long h = 0, g;
38 h = (h << 4) + (
unsigned long)(name[i]);
39 if ((g = (h & 0xF0000000UL))!=0)
52 int i = index % h->
prime;
88 int i = index % h->
prime;
89 for(n = &h->
zen[i]; n != NULL; n = n->
next)
90 if(n->
key != NULL && (n->
keylen==len) && (strncmp(key, n->
key, len) == 0))
135 if(h == NULL || key == NULL)
165 if(h == NULL || key == NULL)
return;
186 if(h == NULL || key == NULL)
return NULL;
192 int i = index % h->
prime;
224 if( !h || !key )
return;
237 if(h == NULL || key == NULL)
return;
255 fprintf(stderr,
"XHASH: table prime: %d , number of elements: %d\n", h->
prime, h->
count );
258 for( i = 0; i< h->
prime ; ++i )
261 fprintf(stderr,
"%d: %d\t", i, h->
stat[i]);
263 fprintf(stderr,
"\n");
273 if(h == NULL || w == NULL)
278 for(i = 0; i < h->
prime; i++)
279 for(n = &h->
zen[i]; n != NULL; n = n->
next)
280 if(n->
key != NULL && n->
val != NULL)
289 if(h == NULL)
return 1;
299 if(h == NULL)
return 0;
312 if(h == NULL)
return 0;
321 if(h == NULL)
return 0;
328 if(n->
key != NULL && n->
val != NULL)
375 if(h == NULL || (key == NULL && val == NULL) || (key != NULL && keylen == NULL))
return 0;
378 if(key != NULL) *key = NULL;
379 if(val != NULL) *val = NULL;
struct xhn_struct * free_list
void * xhash_getx(xht h, const char *key, int len)
void xhash_iter_zap(xht h)
static xhn _xhash_node_new(xht h, int index)
int xhash_iter_next(xht h)
void(* xhash_walker)(const char *key, int keylen, void *val, void *arg)
void * pmalloco(pool_t p, int size)
easy safety utility (for creating blank mem for structs, etc)
void xhash_put(xht h, const char *key, void *val)
static int _xhasher(const char *s, int len)
int xhash_iter_get(xht h, const char **key, int *keylen, void **val)
void xhash_zap(xht h, const char *key)
void xhash_zapx(xht h, const char *key, int len)
static xhn _xhash_node_get(xht h, const char *key, int len, int index)
int xhash_dirty(xht h)
return the dirty flag (and reset)
void xhash_zap_inner(xht h, xhn n, int index)
int xhash_count(xht h)
return the total number of entries in this xht
int xhash_iter_first(xht h)
iteration
void xhash_walk(xht h, xhash_walker w, void *arg)
pool_t xhash_pool(xht h)
get our pool
void * xhash_get(xht h, const char *key)
void xhash_putx(xht h, const char *key, int len, void *val)
pool - base node for a pool.