Lines Matching refs:head
82 #define HASH_FIND(hh,head,keyptr,keylen,out) \ argument
86 if (head) { \
87 HASH_FCN(keyptr,keylen, (head)->hh.tbl->num_buckets, _hf_hashv, _hf_bkt); \
88 if (HASH_BLOOM_TEST((head)->hh.tbl, _hf_hashv)) { \
89 HASH_FIND_IN_BKT((head)->hh.tbl, hh, (head)->hh.tbl->buckets[ _hf_bkt ], \
128 #define HASH_MAKE_TABLE(hh,head) \ argument
130 (head)->hh.tbl = (UT_hash_table*)uthash_malloc( \
132 if (!((head)->hh.tbl)) { uthash_fatal( "out of memory"); } \
133 memset((head)->hh.tbl, 0, sizeof(UT_hash_table)); \
134 (head)->hh.tbl->tail = &((head)->hh); \
135 (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \
136 (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \
137 (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head); \
138 (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc( \
140 if (! (head)->hh.tbl->buckets) { uthash_fatal( "out of memory"); } \
141 memset((head)->hh.tbl->buckets, 0, \
143 HASH_BLOOM_MAKE((head)->hh.tbl); \
144 (head)->hh.tbl->signature = HASH_SIGNATURE; \
147 #define HASH_ADD(hh,head,fieldname,keylen_in,add) \ argument
148 HASH_ADD_KEYPTR(hh,head,&add->fieldname,keylen_in,add)
150 #define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add) \ argument
156 if (!(head)) { \
157 head = (add); \
158 (head)->hh.prev = NULL; \
159 HASH_MAKE_TABLE(hh,head); \
161 (head)->hh.tbl->tail->next = (add); \
162 (add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail); \
163 (head)->hh.tbl->tail = &((add)->hh); \
165 (head)->hh.tbl->num_items++; \
166 (add)->hh.tbl = (head)->hh.tbl; \
167 HASH_FCN(keyptr,keylen_in, (head)->hh.tbl->num_buckets, \
169 HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt],&(add)->hh); \
170 HASH_BLOOM_ADD((head)->hh.tbl,(add)->hh.hashv); \
171 HASH_EMIT_KEY(hh,head,keyptr,keylen_in); \
172 HASH_FSCK(hh,head); \
192 #define HASH_DELETE(hh,head,delptr) \ argument
197 uthash_free((head)->hh.tbl->buckets, \
198 (head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket) ); \
199 HASH_BLOOM_FREE((head)->hh.tbl); \
200 uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
201 head = NULL; \
204 if ((delptr) == ELMT_FROM_HH((head)->hh.tbl,(head)->hh.tbl->tail)) { \
205 (head)->hh.tbl->tail = \
207 (head)->hh.tbl->hho); \
211 (head)->hh.tbl->hho))->next = (delptr)->hh.next; \
213 DECLTYPE_ASSIGN(head,(delptr)->hh.next); \
217 (head)->hh.tbl->hho))->prev = \
220 HASH_TO_BKT( _hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \
221 HASH_DEL_IN_BKT(hh,(head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del); \
222 (head)->hh.tbl->num_items--; \
224 HASH_FSCK(hh,head); \
229 #define HASH_FIND_STR(head,findstr,out) \ argument
230 HASH_FIND(hh,head,findstr,strlen(findstr),out)
231 #define HASH_ADD_STR(head,strfield,add) \ argument
232 HASH_ADD(hh,head,strfield,strlen(add->strfield),add)
233 #define HASH_FIND_INT(head,findint,out) \ argument
234 HASH_FIND(hh,head,findint,sizeof(int),out)
235 #define HASH_ADD_INT(head,intfield,add) \ argument
236 HASH_ADD(hh,head,intfield,sizeof(int),add)
237 #define HASH_FIND_PTR(head,findptr,out) \ argument
238 HASH_FIND(hh,head,findptr,sizeof(void *),out)
239 #define HASH_ADD_PTR(head,ptrfield,add) \ argument
240 HASH_ADD(hh,head,ptrfield,sizeof(void *),add)
241 #define HASH_DEL(head,delptr) \ argument
242 HASH_DELETE(hh,head,delptr)
249 #define HASH_FSCK(hh,head) \ argument
255 if (head) { \
257 for( _bkt_i = 0; _bkt_i < (head)->hh.tbl->num_buckets; _bkt_i++) { \
259 _thh = (head)->hh.tbl->buckets[_bkt_i].hh_head; \
271 if ((head)->hh.tbl->buckets[_bkt_i].count != _bkt_count) { \
273 (head)->hh.tbl->buckets[_bkt_i].count, _bkt_count); \
276 if (_count != (head)->hh.tbl->num_items) { \
278 (head)->hh.tbl->num_items, _count ); \
283 _thh = &(head)->hh; \
290 _prev = (char*)ELMT_FROM_HH((head)->hh.tbl, _thh); \
292 (head)->hh.tbl->hho) : NULL ); \
294 if (_count != (head)->hh.tbl->num_items) { \
296 (head)->hh.tbl->num_items, _count ); \
301 #define HASH_FSCK(hh,head) argument
308 #define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) \ argument
315 #define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) argument
636 #define HASH_FIND_IN_BKT(tbl,hh,head,keyptr,keylen_in,out) \ argument
638 if (head.hh_head) DECLTYPE_ASSIGN(out,ELMT_FROM_HH(tbl,head.hh_head)); \
650 #define HASH_ADD_TO_BKT(head,addhh) \ argument
652 head.count++; \
653 (addhh)->hh_next = head.hh_head; \
655 if (head.hh_head) { (head).hh_head->hh_prev = (addhh); } \
656 (head).hh_head=addhh; \
657 if (head.count >= ((head.expand_mult+1) * HASH_BKT_CAPACITY_THRESH) \
664 #define HASH_DEL_IN_BKT(hh,head,hh_del) \ argument
665 (head).count--; \
666 if ((head).hh_head == hh_del) { \
667 (head).hh_head = hh_del->hh_next; \
757 #define HASH_SORT(head,cmpfcn) HASH_SRT(hh,head,cmpfcn) argument
758 #define HASH_SRT(hh,head,cmpfcn) \ argument
763 if (head) { \
766 _hs_list = &((head)->hh); \
780 (head)->hh.tbl->hho)) : NULL); \
789 (head)->hh.tbl->hho)) : NULL); \
795 (head)->hh.tbl->hho)) : NULL); \
798 cmpfcn(DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_p)), \
799 DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_q))) \
804 (head)->hh.tbl->hho)) : NULL); \
810 (head)->hh.tbl->hho)) : NULL); \
815 ELMT_FROM_HH((head)->hh.tbl,_hs_e) : NULL); \
820 ELMT_FROM_HH((head)->hh.tbl,_hs_tail) : NULL); \
828 (head)->hh.tbl->tail = _hs_tail; \
829 DECLTYPE_ASSIGN(head,ELMT_FROM_HH((head)->hh.tbl, _hs_list)); \
833 HASH_FSCK(hh,head); \
880 #define HASH_CLEAR(hh,head) \ argument
882 if (head) { \
883 uthash_free((head)->hh.tbl->buckets, \
884 (head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket)); \
885 uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
886 (head)=NULL; \
891 #define HASH_ITER(hh,head,el,tmp) \ argument
892 for((el)=(head), (*(char**)(&(tmp)))=(char*)((head)?(head)->hh.next:NULL); \
895 #define HASH_ITER(hh,head,el,tmp) \ argument
896 for((el)=(head),(tmp)=DECLTYPE(el)((head)?(head)->hh.next:NULL); \
901 #define HASH_COUNT(head) HASH_CNT(hh,head) argument
902 #define HASH_CNT(hh,head) ((head)?((head)->hh.tbl->num_items):0) argument