| 376 | } |
| 377 | |
| 378 | bool htable_add_(struct htable *ht, size_t hash, const void *p) |
| 379 | { |
| 380 | /* Cannot insert NULL, or (void *)1. */ |
| 381 | assert(p); |
| 382 | assert(entry_is_valid((uintptr_t)p)); |
| 383 | |
| 384 | /* Getting too full? */ |
| 385 | if (ht->elems+1 + ht->deleted > ht_max(ht)) { |
| 386 | /* If we're more than 1/8 deleted, clean those, |
| 387 | * otherwise double table size. */ |
| 388 | if (ht->deleted > ht_max_deleted(ht)) |
| 389 | rehash_table(ht); |
| 390 | else if (!double_table(ht)) |
| 391 | return false; |
| 392 | } |
| 393 | if (((uintptr_t)p & ht->common_mask) != ht->common_bits) |
| 394 | update_common(ht, p); |
| 395 | |
| 396 | ht_add(ht, p, hash); |
| 397 | ht->elems++; |
| 398 | return true; |
| 399 | } |
| 400 | |
| 401 | bool htable_del_(struct htable *ht, size_t h, const void *p) |
| 402 | { |
nothing calls this directly
no test coverage detected