| 74 | #define HASHMAP_LOAD_FACTOR 80 |
| 75 | |
| 76 | static void alloc_table(struct hashmap *map, unsigned int size) |
| 77 | { |
| 78 | map->tablesize = size; |
| 79 | CALLOC_ARRAY(map->table, size); |
| 80 | |
| 81 | /* calculate resize thresholds for new size */ |
| 82 | map->grow_at = (unsigned int) ((uint64_t) size * HASHMAP_LOAD_FACTOR / 100); |
| 83 | if (size <= HASHMAP_INITIAL_SIZE) |
| 84 | map->shrink_at = 0; |
| 85 | else |
| 86 | /* |
| 87 | * The shrink-threshold must be slightly smaller than |
| 88 | * (grow-threshold / resize-factor) to prevent erratic resizing, |
| 89 | * thus we divide by (resize-factor + 1). |
| 90 | */ |
| 91 | map->shrink_at = map->grow_at / ((1 << HASHMAP_RESIZE_BITS) + 1); |
| 92 | } |
| 93 | |
| 94 | static inline int entry_equals(const struct hashmap *map, |
| 95 | const struct hashmap_entry *e1, |
no outgoing calls
no test coverage detected