if (ht->ht_vec == 0)
{
fprintf (stderr, _("can't allocate %lu bytes for hash table: memory exhausted"),
- ht->ht_size * (unsigned long) sizeof (struct token *));
+ ht->ht_size * (unsigned long) sizeof (struct token *));
exit (MAKE_TROUBLE);
}
slot = &ht->ht_vec[hash_1];
if (*slot == 0)
- return (deleted_slot ? deleted_slot : slot);
+ return (deleted_slot ? deleted_slot : slot);
if (*slot == hash_deleted_item)
- {
- if (deleted_slot == 0)
- deleted_slot = slot;
- }
+ {
+ if (deleted_slot == 0)
+ deleted_slot = slot;
+ }
else
- {
- if (key == *slot)
- return slot;
- if ((*ht->ht_compare) (key, *slot) == 0)
- return slot;
- ht->ht_collisions++;
- }
+ {
+ if (key == *slot)
+ return slot;
+ if ((*ht->ht_compare) (key, *slot) == 0)
+ return slot;
+ ht->ht_collisions++;
+ }
if (!hash_2)
- hash_2 = (*ht->ht_hash_2) (key) | 1;
+ hash_2 = (*ht->ht_hash_2) (key) | 1;
hash_1 += hash_2;
}
}
{
ht->ht_fill++;
if (old_item == 0)
- ht->ht_empty_slots--;
+ ht->ht_empty_slots--;
old_item = item;
}
*(void const **) slot = item;
{
void *item = *vec;
if (!HASH_VACANT (item))
- free (item);
+ free (item);
*vec = 0;
}
ht->ht_fill = 0;
for (slot = ht->ht_vec; slot < end; slot++)
{
if (!HASH_VACANT (*slot))
- (*map) (*slot);
+ (*map) (*slot);
}
}
for (slot = ht->ht_vec; slot < end; slot++)
{
if (!HASH_VACANT (*slot))
- (*map) (*slot, arg);
+ (*map) (*slot, arg);
}
}
for (ovp = old_vec; ovp < &old_vec[old_ht_size]; ovp++)
{
if (! HASH_VACANT (*ovp))
- {
- void **slot = hash_find_slot (ht, *ovp);
- *slot = *ovp;
- }
+ {
+ void **slot = hash_find_slot (ht, *ovp);
+ *slot = *ovp;
+ }
}
ht->ht_empty_slots = ht->ht_size - ht->ht_fill;
free (old_vec);
hash_print_stats (struct hash_table *ht, FILE *out_FILE)
{
fprintf (out_FILE, _("Load=%lu/%lu=%.0f%%, "), ht->ht_fill, ht->ht_size,
- 100.0 * (double) ht->ht_fill / (double) ht->ht_size);
+ 100.0 * (double) ht->ht_fill / (double) ht->ht_size);
fprintf (out_FILE, _("Rehash=%u, "), ht->ht_rehashes);
fprintf (out_FILE, _("Collisions=%lu/%lu=%.0f%%"), ht->ht_collisions, ht->ht_lookups,
- (ht->ht_lookups
- ? (100.0 * (double) ht->ht_collisions / (double) ht->ht_lookups)
- : 0));
+ (ht->ht_lookups
+ ? (100.0 * (double) ht->ht_collisions / (double) ht->ht_lookups)
+ : 0));
}
/* Dump all items into a NULL-terminated vector. Use the
}
#define rol32(v, n) \
- ((v) << (n) | ((v) >> (32 - (n))))
+ ((v) << (n) | ((v) >> (32 - (n))))
/* jhash_mix -- mix 3 32-bit values reversibly. */
#define jhash_mix(a, b, c) \
} while (0)
#endif
+/* This function performs magic which is correct but causes ASAN heartburn
+ when we pass in a global constant string (at least). */
+__attribute__((no_sanitize_address))
unsigned jhash_string(unsigned const char *k)
{
unsigned int a, b, c;