Lines Matching refs:hh

103 #define HASH_FIND(hh,head,keyptr,keylen,out)                                     \  argument
108 HASH_FCN(keyptr,keylen, (head)->hh.tbl->num_buckets, _hf_hashv, _hf_bkt); \
109 if (HASH_BLOOM_TEST((head)->hh.tbl, _hf_hashv)) { \
110 HASH_FIND_IN_BKT((head)->hh.tbl, hh, (head)->hh.tbl->buckets[ _hf_bkt ], \
150 #define HASH_MAKE_TABLE(hh,head) \ argument
152 (head)->hh.tbl = (UT_hash_table*)uthash_malloc( \
154 if (!((head)->hh.tbl)) { uthash_fatal( "out of memory"); } \
155 memset((head)->hh.tbl, 0, sizeof(UT_hash_table)); \
156 (head)->hh.tbl->tail = &((head)->hh); \
157 (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \
158 (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \
159 (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head); \
160 (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc( \
162 if (! (head)->hh.tbl->buckets) { uthash_fatal( "out of memory"); } \
163 memset((head)->hh.tbl->buckets, 0, \
165 HASH_BLOOM_MAKE((head)->hh.tbl); \
166 (head)->hh.tbl->signature = HASH_SIGNATURE; \
169 #define HASH_ADD(hh,head,fieldname,keylen_in,add) \ argument
170 HASH_ADD_KEYPTR(hh,head,&((add)->fieldname),keylen_in,add)
172 #define HASH_REPLACE(hh,head,fieldname,keylen_in,add,replaced) \ argument
175 HASH_FIND(hh,head,&((add)->fieldname),keylen_in,replaced); \
177 HASH_DELETE(hh,head,replaced); \
179 HASH_ADD(hh,head,fieldname,keylen_in,add); \
182 #define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add) \ argument
185 (add)->hh.next = NULL; \
186 (add)->hh.key = (char*)(keyptr); \
187 (add)->hh.keylen = (unsigned)(keylen_in); \
190 (head)->hh.prev = NULL; \
191 HASH_MAKE_TABLE(hh,head); \
193 (head)->hh.tbl->tail->next = (add); \
194 (add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail); \
195 (head)->hh.tbl->tail = &((add)->hh); \
197 (head)->hh.tbl->num_items++; \
198 (add)->hh.tbl = (head)->hh.tbl; \
199 HASH_FCN(keyptr,keylen_in, (head)->hh.tbl->num_buckets, \
200 (add)->hh.hashv, _ha_bkt); \
201 HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt],&(add)->hh); \
202 HASH_BLOOM_ADD((head)->hh.tbl,(add)->hh.hashv); \
203 HASH_EMIT_KEY(hh,head,keyptr,keylen_in); \
204 HASH_FSCK(hh,head); \
224 #define HASH_DELETE(hh,head,delptr) \ argument
227 if ( ((delptr)->hh.prev == NULL) && ((delptr)->hh.next == NULL) ) { \
228 uthash_free((head)->hh.tbl->buckets, \
229 (head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket) ); \
230 HASH_BLOOM_FREE((head)->hh.tbl); \
231 uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
235 _hd_hh_del = &((delptr)->hh); \
236 if ((delptr) == ELMT_FROM_HH((head)->hh.tbl,(head)->hh.tbl->tail)) { \
237 (head)->hh.tbl->tail = \
238 (UT_hash_handle*)((ptrdiff_t)((delptr)->hh.prev) + \
239 (head)->hh.tbl->hho); \
241 if ((delptr)->hh.prev) { \
242 ((UT_hash_handle*)((ptrdiff_t)((delptr)->hh.prev) + \
243 (head)->hh.tbl->hho))->next = (delptr)->hh.next; \
245 DECLTYPE_ASSIGN(head,(delptr)->hh.next); \
249 (head)->hh.tbl->hho))->prev = \
252 HASH_TO_BKT( _hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \
253 HASH_DEL_IN_BKT(hh,(head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del); \
254 (head)->hh.tbl->num_items--; \
256 HASH_FSCK(hh,head); \
262 HASH_FIND(hh,head,findstr,(unsigned)strlen(findstr),out)
264 HASH_ADD(hh,head,strfield[0],strlen(add->strfield),add)
266 HASH_REPLACE(hh,head,strfield[0],(unsigned)strlen(add->strfield),add,replaced)
268 HASH_FIND(hh,head,findint,sizeof(int),out)
270 HASH_ADD(hh,head,intfield,sizeof(int),add)
272 HASH_REPLACE(hh,head,intfield,sizeof(int),add,replaced)
274 HASH_FIND(hh,head,findptr,sizeof(void *),out)
276 HASH_ADD(hh,head,ptrfield,sizeof(void *),add)
278 HASH_REPLACE(hh,head,ptrfield,sizeof(void *),add,replaced)
280 HASH_DELETE(hh,head,delptr)
287 #define HASH_FSCK(hh,head) \ argument
295 for( _bkt_i = 0; _bkt_i < (head)->hh.tbl->num_buckets; _bkt_i++) { \
297 _thh = (head)->hh.tbl->buckets[_bkt_i].hh_head; \
309 if ((head)->hh.tbl->buckets[_bkt_i].count != _bkt_count) { \
311 (head)->hh.tbl->buckets[_bkt_i].count, _bkt_count); \
314 if (_count != (head)->hh.tbl->num_items) { \
316 (head)->hh.tbl->num_items, _count ); \
321 _thh = &(head)->hh; \
328 _prev = (char*)ELMT_FROM_HH((head)->hh.tbl, _thh); \
330 (head)->hh.tbl->hho) : NULL ); \
332 if (_count != (head)->hh.tbl->num_items) { \
334 (head)->hh.tbl->num_items, _count ); \
339 #define HASH_FSCK(hh,head) argument
346 #define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) \ argument
353 #define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) argument
611 #define HASH_FIND_IN_BKT(tbl,hh,head,keyptr,keylen_in,out) \ argument
616 if ((out)->hh.keylen == keylen_in) { \
617 if ((HASH_KEYCMP((out)->hh.key,keyptr,keylen_in)) == 0) break; \
619 if ((out)->hh.hh_next) DECLTYPE_ASSIGN(out,ELMT_FROM_HH(tbl,(out)->hh.hh_next)); \
639 #define HASH_DEL_IN_BKT(hh,head,hh_del) \ argument
732 #define HASH_SORT(head,cmpfcn) HASH_SRT(hh,head,cmpfcn)
733 #define HASH_SRT(hh,head,cmpfcn) \ argument
741 _hs_list = &((head)->hh); \
755 (head)->hh.tbl->hho)) : NULL); \
764 (head)->hh.tbl->hho)) : NULL); \
771 (head)->hh.tbl->hho)) : NULL); \
775 cmpfcn(DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_p)), \
776 DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_q))) \
782 (head)->hh.tbl->hho)) : NULL); \
789 (head)->hh.tbl->hho)) : NULL); \
794 ELMT_FROM_HH((head)->hh.tbl,_hs_e) : NULL); \
800 ELMT_FROM_HH((head)->hh.tbl,_hs_tail) : NULL); \
811 (head)->hh.tbl->tail = _hs_tail; \
812 DECLTYPE_ASSIGN(head,ELMT_FROM_HH((head)->hh.tbl, _hs_list)); \
816 HASH_FSCK(hh,head); \
863 #define HASH_CLEAR(hh,head) \ argument
866 uthash_free((head)->hh.tbl->buckets, \
867 (head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket)); \
868 HASH_BLOOM_FREE((head)->hh.tbl); \
869 uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
874 #define HASH_OVERHEAD(hh,head) \ argument
876 (size_t)((((head)->hh.tbl->num_items * sizeof(UT_hash_handle)) + \
877 ((head)->hh.tbl->num_buckets * sizeof(UT_hash_bucket)) + \
882 #define HASH_ITER(hh,head,el,tmp) \ argument
883 for((el)=(head), (*(char**)(&(tmp)))=(char*)((head)?(head)->hh.next:NULL); \
884 el; (el)=(tmp),(*(char**)(&(tmp)))=(char*)((tmp)?(tmp)->hh.next:NULL))
886 #define HASH_ITER(hh,head,el,tmp) \ argument
887 for((el)=(head),(tmp)=DECLTYPE(el)((head)?(head)->hh.next:NULL); \
888 el; (el)=(tmp),(tmp)=DECLTYPE(el)((tmp)?(tmp)->hh.next:NULL))
892 #define HASH_COUNT(head) HASH_CNT(hh,head)
893 #define HASH_CNT(hh,head) ((head)?((head)->hh.tbl->num_items):0) argument