Lines Matching full:head

119 #define HASH_FIND_BYHASHVALUE(hh,head,keyptr,keylen,hashval,out)                 \  argument
122 if (head) { \
124 HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _hf_bkt); \
125 if (HASH_BLOOM_TEST((head)->hh.tbl, hashval) != 0) { \
126 …HASH_FIND_IN_BKT((head)->hh.tbl, hh, (head)->hh.tbl->buckets[ _hf_bkt ], keyptr, keylen, hashval, …
131 #define HASH_FIND(hh,head,keyptr,keylen,out) \ argument
135 HASH_FIND_BYHASHVALUE(hh, head, keyptr, keylen, _hf_hashv, out); \
172 #define HASH_MAKE_TABLE(hh,head) \ argument
174 (head)->hh.tbl = (UT_hash_table*)uthash_malloc( \
176 if (!((head)->hh.tbl)) { uthash_fatal( "out of memory"); } \
177 memset((head)->hh.tbl, 0, sizeof(UT_hash_table)); \
178 (head)->hh.tbl->tail = &((head)->hh); \
179 (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \
180 (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \
181 (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head); \
182 (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc( \
184 if (! (head)->hh.tbl->buckets) { uthash_fatal( "out of memory"); } \
185 memset((head)->hh.tbl->buckets, 0, \
187 HASH_BLOOM_MAKE((head)->hh.tbl); \
188 (head)->hh.tbl->signature = HASH_SIGNATURE; \
191 #define HASH_REPLACE_BYHASHVALUE_INORDER(hh,head,fieldname,keylen_in,hashval,add,replaced,cmpfcn) \ argument
194 HASH_FIND_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, replaced); \
196 HASH_DELETE(hh, head, replaced); \
198 …HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, &((add)->fieldname), keylen_in, hashval, add, cmpfcn…
201 #define HASH_REPLACE_BYHASHVALUE(hh,head,fieldname,keylen_in,hashval,add,replaced) \ argument
204 HASH_FIND_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, replaced); \
206 HASH_DELETE(hh, head, replaced); \
208 HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, add); \
211 #define HASH_REPLACE(hh,head,fieldname,keylen_in,add,replaced) \ argument
215 HASH_REPLACE_BYHASHVALUE(hh, head, fieldname, keylen_in, _hr_hashv, add, replaced); \
218 #define HASH_REPLACE_INORDER(hh,head,fieldname,keylen_in,add,replaced,cmpfcn) \ argument
222 …HASH_REPLACE_BYHASHVALUE_INORDER(hh, head, fieldname, keylen_in, _hr_hashv, add, replaced, cmpfcn)…
225 #define HASH_APPEND_LIST(hh, head, add) \ argument
228 (add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail); \
229 (head)->hh.tbl->tail->next = (add); \
230 (head)->hh.tbl->tail = &((add)->hh); \
233 #define HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh,head,keyptr,keylen_in,hashval,add,cmpfcn) \ argument
239 if (!(head)) { \
242 (head) = (add); \
243 HASH_MAKE_TABLE(hh, head); \
245 struct UT_hash_handle *_hs_iter = &(head)->hh; \
246 (add)->hh.tbl = (head)->hh.tbl; \
248 if (cmpfcn(DECLTYPE(head) ELMT_FROM_HH((head)->hh.tbl, _hs_iter), add) > 0) \
254 HH_FROM_ELMT((head)->hh.tbl, _hs_iter->prev)->next = (add); \
256 (head) = (add); \
260 HASH_APPEND_LIST(hh, head, add); \
263 (head)->hh.tbl->num_items++; \
264 HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \
265 HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], &(add)->hh); \
266 HASH_BLOOM_ADD((head)->hh.tbl, hashval); \
267 HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \
268 HASH_FSCK(hh, head); \
271 #define HASH_ADD_KEYPTR_INORDER(hh,head,keyptr,keylen_in,add,cmpfcn) \ argument
275 HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, keyptr, keylen_in, _hs_hashv, add, cmpfcn); \
278 #define HASH_ADD_BYHASHVALUE_INORDER(hh,head,fieldname,keylen_in,hashval,add,cmpfcn) \ argument
279 …HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, &((add)->fieldname), keylen_in, hashval, add, cmpfcn)
281 #define HASH_ADD_INORDER(hh,head,fieldname,keylen_in,add,cmpfcn) \ argument
282 HASH_ADD_KEYPTR_INORDER(hh, head, &((add)->fieldname), keylen_in, add, cmpfcn)
284 #define HASH_ADD_KEYPTR_BYHASHVALUE(hh,head,keyptr,keylen_in,hashval,add) \ argument
290 if (!(head)) { \
293 (head) = (add); \
294 HASH_MAKE_TABLE(hh, head); \
296 (add)->hh.tbl = (head)->hh.tbl; \
297 HASH_APPEND_LIST(hh, head, add); \
299 (head)->hh.tbl->num_items++; \
300 HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \
301 HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], &(add)->hh); \
302 HASH_BLOOM_ADD((head)->hh.tbl, hashval); \
303 HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \
304 HASH_FSCK(hh, head); \
307 #define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add) \ argument
311 HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, keyptr, keylen_in, _ha_hashv, add); \
314 #define HASH_ADD_BYHASHVALUE(hh,head,fieldname,keylen_in,hashval,add) \ argument
315 HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, add)
317 #define HASH_ADD(hh,head,fieldname,keylen_in,add) \ argument
318 HASH_ADD_KEYPTR(hh, head, &((add)->fieldname), keylen_in, add)
329 * if someone used the same symbol for the head and deletee, like
331 * We want that to work, but by changing the head (users) below
337 #define HASH_DELETE(hh,head,delptr) \ argument
341 uthash_free((head)->hh.tbl->buckets, \
342 (head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket) ); \
343 HASH_BLOOM_FREE((head)->hh.tbl); \
344 uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
345 head = NULL; \
349 if ((delptr) == ELMT_FROM_HH((head)->hh.tbl,(head)->hh.tbl->tail)) { \
350 (head)->hh.tbl->tail = \
352 (head)->hh.tbl->hho); \
356 (head)->hh.tbl->hho))->next = (delptr)->hh.next; \
358 DECLTYPE_ASSIGN(head,(delptr)->hh.next); \
362 (head)->hh.tbl->hho))->prev = \
365 HASH_TO_BKT( _hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \
366 HASH_DEL_IN_BKT(hh,(head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del); \
367 (head)->hh.tbl->num_items--; \
369 HASH_FSCK(hh,head); \
374 #define HASH_FIND_STR(head,findstr,out) \ argument
375 HASH_FIND(hh,head,findstr,(unsigned)uthash_strlen(findstr),out)
376 #define HASH_ADD_STR(head,strfield,add) \ argument
377 HASH_ADD(hh,head,strfield[0],(unsigned)uthash_strlen(add->strfield),add)
378 #define HASH_REPLACE_STR(head,strfield,add,replaced) \ argument
379 HASH_REPLACE(hh,head,strfield[0],(unsigned)uthash_strlen(add->strfield),add,replaced)
380 #define HASH_FIND_INT(head,findint,out) \ argument
381 HASH_FIND(hh,head,findint,sizeof(int),out)
382 #define HASH_ADD_INT(head,intfield,add) \ argument
383 HASH_ADD(hh,head,intfield,sizeof(int),add)
384 #define HASH_REPLACE_INT(head,intfield,add,replaced) \ argument
385 HASH_REPLACE(hh,head,intfield,sizeof(int),add,replaced)
386 #define HASH_FIND_PTR(head,findptr,out) \ argument
387 HASH_FIND(hh,head,findptr,sizeof(void *),out)
388 #define HASH_ADD_PTR(head,ptrfield,add) \ argument
389 HASH_ADD(hh,head,ptrfield,sizeof(void *),add)
390 #define HASH_REPLACE_PTR(head,ptrfield,add,replaced) \ argument
391 HASH_REPLACE(hh,head,ptrfield,sizeof(void *),add,replaced)
392 #define HASH_DEL(head,delptr) \ argument
393 HASH_DELETE(hh,head,delptr)
400 #define HASH_FSCK(hh,head) \ argument
403 if (head) { \
408 for( _bkt_i = 0; _bkt_i < (head)->hh.tbl->num_buckets; _bkt_i++) { \
410 _thh = (head)->hh.tbl->buckets[_bkt_i].hh_head; \
422 if ((head)->hh.tbl->buckets[_bkt_i].count != _bkt_count) { \
424 (head)->hh.tbl->buckets[_bkt_i].count, _bkt_count); \
427 if (_count != (head)->hh.tbl->num_items) { \
429 (head)->hh.tbl->num_items, _count ); \
434 _thh = &(head)->hh; \
441 _prev = (char*)ELMT_FROM_HH((head)->hh.tbl, _thh); \
443 (head)->hh.tbl->hho) : NULL ); \
445 if (_count != (head)->hh.tbl->num_items) { \
447 (head)->hh.tbl->num_items, _count ); \
452 #define HASH_FSCK(hh,head) argument
459 #define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) \ argument
466 #define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) argument
714 #define HASH_FIND_IN_BKT(tbl,hh,head,keyptr,keylen_in,hashval,out) \ argument
716 if ((head).hh_head != NULL) { \
717 DECLTYPE_ASSIGN(out, ELMT_FROM_HH(tbl, (head).hh_head)); \
736 #define HASH_ADD_TO_BKT(head,addhh) \ argument
738 head.count++; \
739 (addhh)->hh_next = head.hh_head; \
741 if (head.hh_head != NULL) { (head).hh_head->hh_prev = (addhh); } \
742 (head).hh_head=addhh; \
743 if ((head.count >= ((head.expand_mult+1U) * HASH_BKT_CAPACITY_THRESH)) \
750 #define HASH_DEL_IN_BKT(hh,head,hh_del) \ argument
751 (head).count--; \
752 if ((head).hh_head == hh_del) { \
753 (head).hh_head = hh_del->hh_next; \
843 #define HASH_SORT(head,cmpfcn) HASH_SRT(hh,head,cmpfcn) argument
844 #define HASH_SRT(hh,head,cmpfcn) \ argument
849 if (head != NULL) { \
852 _hs_list = &((head)->hh); \
866 (head)->hh.tbl->hho)) : NULL); \
875 (head)->hh.tbl->hho)) : NULL); \
882 (head)->hh.tbl->hho)) : NULL); \
886 cmpfcn(DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_p)), \
887 DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_q))) \
893 (head)->hh.tbl->hho)) : NULL); \
900 (head)->hh.tbl->hho)) : NULL); \
905 ELMT_FROM_HH((head)->hh.tbl,_hs_e) : NULL); \
911 ELMT_FROM_HH((head)->hh.tbl,_hs_tail) : NULL); \
922 (head)->hh.tbl->tail = _hs_tail; \
923 DECLTYPE_ASSIGN(head,ELMT_FROM_HH((head)->hh.tbl, _hs_list)); \
927 HASH_FSCK(hh,head); \
974 #define HASH_CLEAR(hh,head) \ argument
976 if (head != NULL) { \
977 uthash_free((head)->hh.tbl->buckets, \
978 (head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket)); \
979 HASH_BLOOM_FREE((head)->hh.tbl); \
980 uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
981 (head)=NULL; \
985 #define HASH_OVERHEAD(hh,head) \ argument
986 ((head != NULL) ? ( \
987 (size_t)(((head)->hh.tbl->num_items * sizeof(UT_hash_handle)) + \
988 ((head)->hh.tbl->num_buckets * sizeof(UT_hash_bucket)) + \
993 #define HASH_ITER(hh,head,el,tmp) \ argument
994 for(((el)=(head)), ((*(char**)(&(tmp)))=(char*)((head!=NULL)?(head)->hh.next:NULL)); \
997 #define HASH_ITER(hh,head,el,tmp) \ argument
998 for(((el)=(head)), ((tmp)=DECLTYPE(el)((head!=NULL)?(head)->hh.next:NULL)); \
1003 #define HASH_COUNT(head) HASH_CNT(hh,head) argument
1004 #define HASH_CNT(hh,head) ((head != NULL)?((head)->hh.tbl->num_items):0U) argument