Lines Matching refs:hash

35 /* internal data structure for hash table with chaining */
40 Dtlink_t** htbl; /* hash table slots */
41 ssize_t tblz; /* size of hash table */
44 /* make/resize hash table */
50 Dthash_t *hash = (Dthash_t*)dt->data;
52 if((n = hash->tblz) > 0 && (hash->type&H_FIXED) )
58 { hash->type |= H_FIXED;
65 n = n < HLOAD(hash->data.size) ? HLOAD(hash->data.size) : n;
68 if((n = k) <= hash->tblz)
73 { DTERROR(dt, "Error in allocating an extended hash table");
79 for(endt = (t = hash->htbl) + hash->tblz; t < endt; ++t)
87 if(hash->htbl) /* free old table and set new table */
88 (void)(*dt->memoryf)(dt, hash->htbl, 0, disc);
89 hash->htbl = htbl;
90 hash->tblz = n;
98 Dthash_t *hash = (Dthash_t*)dt->data;
100 hash->here = NIL(Dtlink_t*);
101 hash->data.size = 0;
103 for(endt = (t = hash->htbl) + hash->tblz; t < endt; ++t)
117 Dthash_t *hash = (Dthash_t*)dt->data;
119 for(endt = (t = hash->htbl) + hash->tblz; t < endt; ++t)
122 hash->here = l;
132 Dthash_t *hash = (Dthash_t*)dt->data;
135 { hash->here = next;
139 { t = hash->htbl + (l->_hash & (hash->tblz-1)) + 1;
140 endt = hash->htbl + hash->tblz;
144 hash->here = l;
154 Dthash_t *hash = (Dthash_t*)dt->data;
158 for(endt = (t = hash->htbl) + hash->tblz; t < endt; ++t)
169 { hash->here = head;
170 hash->type |= H_FLATTEN;
172 else hash->data.size = 0;
177 { head = hash->here;
178 for(endt = (t = hash->htbl) + hash->tblz; t < endt; ++t)
193 hash->here = NIL(Dtlink_t*);
194 hash->type &= ~H_FLATTEN;
226 Dthash_t *hash = (Dthash_t*)dt->data;
231 st->size = hash->data.size;
232 st->space = sizeof(Dthash_t) + hash->tblz*sizeof(Dtlink_t*) +
233 (dt->disc->link >= 0 ? 0 : hash->data.size*sizeof(Dthold_t));
235 for(endt = (t = hash->htbl) + hash->tblz; t < endt; ++t)
246 return (Void_t*)hash->data.size;
262 Dthash_t *hash = (Dthash_t*)dt->data;
270 if(!hash->htbl && htable(dt) < 0 ) /* initialize hash table */
273 if(hash->type&H_FLATTEN) /* restore flattened list */
287 lnk = hash->here; /* fingered object */
288 hash->here = NIL(Dtlink_t*);
312 tbl = hash->htbl + (hsh & (hash->tblz-1));
332 { hash->here = ll;
338 { hash->data.size -= 1;
362 if(hash->tblz < HLOAD(hash->data.size) )
364 tbl = hash->htbl + (hsh & (hash->tblz-1));
370 hash->data.size += 1;
373 lnk->_hash = hsh; /* memoize the hash value */
376 hash->here = lnk;
388 Dthash_t *hash = (Dthash_t*)dt->data;
391 { if(hash)
393 if(!(hash = (Dthash_t*)(*dt->memoryf)(dt, 0, sizeof(Dthash_t), dt->disc)) )
394 { DTERROR(dt, "Error in allocating a hash table with chaining");
397 memset(hash, 0, sizeof(Dthash_t));
398 dt->data = (Dtdata_t*)hash;
402 { if(!hash)
404 if(hash->data.size > 0 )
406 if(hash->htbl)
407 (void)(*dt->memoryf)(dt, hash->htbl, 0, dt->disc);
408 (void)(*dt->memoryf)(dt, hash, 0, dt->disc);