| 411 | } |
| 412 | |
| 413 | static bool seen_set_insert(seen_set_t *s, int64_t node_id) { |
| 414 | if (!s->slots) { |
| 415 | return false; |
| 416 | } |
| 417 | uint32_t idx = (uint32_t)(node_id * KNUTH_MULT) & SEEN_SET_MASK; |
| 418 | for (int probe = 0; probe < SEEN_SET_SIZE; probe++) { |
| 419 | uint32_t slot = (idx + (uint32_t)probe) & SEEN_SET_MASK; |
| 420 | if (s->slots[slot] == 0) { |
| 421 | s->slots[slot] = node_id; |
| 422 | return true; /* inserted (was not present) */ |
| 423 | } |
| 424 | if (s->slots[slot] == node_id) { |
| 425 | return false; /* already present */ |
| 426 | } |
| 427 | } |
| 428 | return false; /* table full */ |
| 429 | } |
| 430 | |
| 431 | static void seen_set_free(seen_set_t *s) { |
| 432 | free(s->slots); |
no outgoing calls
no test coverage detected