diff options
| author | Carson Fleming <[email protected]> | 2026-02-05 23:47:54 -0500 |
|---|---|---|
| committer | Carson Fleming <[email protected]> | 2026-02-05 23:47:54 -0500 |
| commit | 1a08245d480b8a18fcbc80efd8602cdb90d6ed5e (patch) | |
| tree | ce4995d3c1707e07415cfcad7da1a5146332d6f4 /map.c | |
| parent | 7f79eb03b6a6cd21192feda8dcb5a973f3420c7c (diff) | |
| download | safec-1a08245d480b8a18fcbc80efd8602cdb90d6ed5e.tar.gz | |
better crash messages
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; } |
