-
- bucket = NULL;
- list = &bucket;
- remaining = hash[i];
- cnt = 0;
- while (cnt < hlimit && remaining) {
- struct index *this = remaining, *that;
- remaining = remaining->next;
- for (that = bucket; that; that = that->next) {
- if (!memcmp(that->ptr, this->ptr, 3))
- break;
- }
- if (that)
- continue; /* discard */
- cnt++;
- *list = this;
- list = &(this->next);
- this->next = NULL;
- }
- hash[i] = bucket;
+ entry = hash[i];
+ do {
+ struct index *keep = entry;
+ int skip = hash_count[i] / hlimit / 2;
+ do {
+ entry = entry->next;
+ } while(--skip && entry);
+ keep->next = entry;
+ } while(entry);