diff options
Diffstat (limited to 'map.c')
| -rw-r--r-- | map.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -280,7 +280,9 @@ static void rehash_set(set_t* set) { void* key = old_buckets[i]; if (key == NULL) continue; size_t idx = fetch_set_idx(set, key, true); - if (idx >= set->__num_buckets) crash("wtf\n"); // TODO + if (idx >= set->__num_buckets) + crash( + "Set failed rehashing, likely due to bad hash function.\n"); set->__buckets[idx] = key; } free(old_buckets); @@ -290,11 +292,12 @@ static size_t fetch_set_idx_rehashing(set_t* set, void* key) { size_t idx = fetch_set_idx(set, key, true); if ((double) ++set->size / set->__num_buckets > set->load_limit || idx >= set->__num_buckets) { - // TODO: no need for do/while - do { - rehash_set(set); - idx = fetch_set_idx(set, key, true); - } while (idx >= set->__num_buckets); + rehash_set(set); + idx = fetch_set_idx(set, key, true); + if (idx >= set->__num_buckets) + crash( + "Set still full after rehashing, " + "likely due to bad hash function.\n"); } return idx; } |
