Lines Matching refs:tbl

81 #define uthash_noexpand_fyi(tbl)          /* can be defined to log noexpand  */
84 #define uthash_expand_fyi(tbl) /* can be defined to log expands */
93 #define ELMT_FROM_HH(tbl,hhp) ((void*)(((char*)(hhp)) - ((tbl)->hho)))
100 HASH_FCN(keyptr,keylen, (head)->hh.tbl->num_buckets, _hf_hashv, _hf_bkt); \
101 if (HASH_BLOOM_TEST((head)->hh.tbl, _hf_hashv)) { \
102 HASH_FIND_IN_BKT((head)->hh.tbl, hh, (head)->hh.tbl->buckets[ _hf_bkt ], \
111 #define HASH_BLOOM_MAKE(tbl) \
113 (tbl)->bloom_nbits = HASH_BLOOM; \
114 (tbl)->bloom_bv = (uint8_t*)uthash_malloc(HASH_BLOOM_BYTELEN); \
115 if (!((tbl)->bloom_bv)) { uthash_fatal( "out of memory"); } \
116 memset((tbl)->bloom_bv, 0, HASH_BLOOM_BYTELEN); \
117 (tbl)->bloom_sig = HASH_BLOOM_SIGNATURE; \
120 #define HASH_BLOOM_FREE(tbl) \
122 uthash_free((tbl)->bloom_bv, HASH_BLOOM_BYTELEN); \
128 #define HASH_BLOOM_ADD(tbl,hashv) \
129 HASH_BLOOM_BITSET((tbl)->bloom_bv, (hashv & (uint32_t)((1ULL << (tbl)->bloom_nbits) - 1)))
131 #define HASH_BLOOM_TEST(tbl,hashv) \
132 HASH_BLOOM_BITTEST((tbl)->bloom_bv, (hashv & (uint32_t)((1ULL << (tbl)->bloom_nbits) - 1)))
135 #define HASH_BLOOM_MAKE(tbl)
136 #define HASH_BLOOM_FREE(tbl)
137 #define HASH_BLOOM_ADD(tbl,hashv)
138 #define HASH_BLOOM_TEST(tbl,hashv) (1)
144 (head)->hh.tbl = (UT_hash_table*)uthash_malloc( \
146 if (!((head)->hh.tbl)) { uthash_fatal( "out of memory"); } \
147 memset((head)->hh.tbl, 0, sizeof(UT_hash_table)); \
148 (head)->hh.tbl->tail = &((head)->hh); \
149 (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \
150 (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \
151 (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head); \
152 (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc( \
154 if (! (head)->hh.tbl->buckets) { uthash_fatal( "out of memory"); } \
155 memset((head)->hh.tbl->buckets, 0, \
157 HASH_BLOOM_MAKE((head)->hh.tbl); \
158 (head)->hh.tbl->signature = HASH_SIGNATURE; \
185 (head)->hh.tbl->tail->next = (add); \
186 (add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail); \
187 (head)->hh.tbl->tail = &((add)->hh); \
189 (head)->hh.tbl->num_items++; \
190 (add)->hh.tbl = (head)->hh.tbl; \
191 HASH_FCN(keyptr,keylen_in, (head)->hh.tbl->num_buckets, \
193 HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt],&(add)->hh); \
194 HASH_BLOOM_ADD((head)->hh.tbl,(add)->hh.hashv); \
221 uthash_free((head)->hh.tbl->buckets, \
222 (head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket) ); \
223 HASH_BLOOM_FREE((head)->hh.tbl); \
224 uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
228 if ((delptr) == ELMT_FROM_HH((head)->hh.tbl,(head)->hh.tbl->tail)) { \
229 (head)->hh.tbl->tail = \
231 (head)->hh.tbl->hho); \
235 (head)->hh.tbl->hho))->next = (delptr)->hh.next; \
241 (head)->hh.tbl->hho))->prev = \
244 HASH_TO_BKT( _hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \
245 HASH_DEL_IN_BKT(hh,(head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del); \
246 (head)->hh.tbl->num_items--; \
287 for( _bkt_i = 0; _bkt_i < (head)->hh.tbl->num_buckets; _bkt_i++) { \
289 _thh = (head)->hh.tbl->buckets[_bkt_i].hh_head; \
301 if ((head)->hh.tbl->buckets[_bkt_i].count != _bkt_count) { \
303 (head)->hh.tbl->buckets[_bkt_i].count, _bkt_count); \
306 if (_count != (head)->hh.tbl->num_items) { \
308 (head)->hh.tbl->num_items, _count ); \
320 _prev = (char*)ELMT_FROM_HH((head)->hh.tbl, _thh); \
322 (head)->hh.tbl->hho) : NULL ); \
324 if (_count != (head)->hh.tbl->num_items) { \
326 (head)->hh.tbl->num_items, _count ); \
369 #define HASH_FIND_IN_BKT(tbl,hh,head,keyptr,keylen_in,out) \
371 if (head.hh_head) DECLTYPE_ASSIGN(out,ELMT_FROM_HH(tbl,head.hh_head)); \
377 if ((out)->hh.hh_next) DECLTYPE_ASSIGN(out,ELMT_FROM_HH(tbl,(out)->hh.hh_next)); \
391 && (addhh)->tbl->noexpand != 1) { \
392 HASH_EXPAND_BUCKETS((addhh)->tbl); \
420 * The calculation of tbl->ideal_chain_maxlen below deserves some
438 #define HASH_EXPAND_BUCKETS(tbl) \
445 2 * tbl->num_buckets * sizeof(struct UT_hash_bucket)); \
448 2 * tbl->num_buckets * sizeof(struct UT_hash_bucket)); \
449 tbl->ideal_chain_maxlen = \
450 (tbl->num_items >> (tbl->log2_num_buckets+1)) + \
451 ((tbl->num_items & ((tbl->num_buckets*2)-1)) ? 1 : 0); \
452 tbl->nonideal_items = 0; \
453 for(_he_bkt_i = 0; _he_bkt_i < tbl->num_buckets; _he_bkt_i++) \
455 _he_thh = tbl->buckets[ _he_bkt_i ].hh_head; \
458 HASH_TO_BKT( _he_thh->hashv, tbl->num_buckets*2, _he_bkt); \
460 if (++(_he_newbkt->count) > tbl->ideal_chain_maxlen) { \
461 tbl->nonideal_items++; \
463 tbl->ideal_chain_maxlen; \
473 uthash_free( tbl->buckets, tbl->num_buckets*sizeof(struct UT_hash_bucket) ); \
474 tbl->num_buckets *= 2; \
475 tbl->log2_num_buckets++; \
476 tbl->buckets = _he_new_buckets; \
477 tbl->ineff_expands = (tbl->nonideal_items > (tbl->num_items >> 1)) ? \
478 (tbl->ineff_expands+1) : 0; \
479 if (tbl->ineff_expands > 1) { \
480 tbl->noexpand=1; \
481 uthash_noexpand_fyi(tbl); \
483 uthash_expand_fyi(tbl); \
513 (head)->hh.tbl->hho)) : NULL); \
522 (head)->hh.tbl->hho)) : NULL); \
529 (head)->hh.tbl->hho)) : NULL); \
533 cmpfcn(DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_p)), \
534 DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_q))) \
540 (head)->hh.tbl->hho)) : NULL); \
547 (head)->hh.tbl->hho)) : NULL); \
552 ELMT_FROM_HH((head)->hh.tbl,_hs_e) : NULL); \
558 ELMT_FROM_HH((head)->hh.tbl,_hs_tail) : NULL); \
569 (head)->hh.tbl->tail = _hs_tail; \
570 DECLTYPE_ASSIGN(head,ELMT_FROM_HH((head)->hh.tbl, _hs_list)); \
590 for(_src_bkt=0; _src_bkt < (src)->hh_src.tbl->num_buckets; _src_bkt++) { \
591 for(_src_hh = (src)->hh_src.tbl->buckets[_src_bkt].hh_head; \
594 _elt = ELMT_FROM_HH((src)->hh_src.tbl, _src_hh); \
607 _dst_hh->tbl = (dst)->hh_dst.tbl; \
609 HASH_TO_BKT(_dst_hh->hashv, _dst_hh->tbl->num_buckets, _dst_bkt); \
610 HASH_ADD_TO_BKT(_dst_hh->tbl->buckets[_dst_bkt],_dst_hh); \
611 (dst)->hh_dst.tbl->num_items++; \
624 uthash_free((head)->hh.tbl->buckets, \
625 (head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket)); \
626 HASH_BLOOM_FREE((head)->hh.tbl); \
627 uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
633 (size_t)((((head)->hh.tbl->num_items * sizeof(UT_hash_handle)) + \
634 ((head)->hh.tbl->num_buckets * sizeof(UT_hash_bucket)) + \
650 #define HASH_CNT(hh,head) ((head)?((head)->hh.tbl->num_items):0)
710 struct UT_hash_table *tbl;