Append a candidate to the result buffer, growing if needed. */
| 456 | |
| 457 | /* Append a candidate to the result buffer, growing if needed. */ |
| 458 | static bool result_push(cbm_lsh_index_t *idx, const cbm_lsh_entry_t *candidate) { |
| 459 | if (idx->result_count >= idx->result_cap) { |
| 460 | int new_cap = |
| 461 | idx->result_cap < RESULT_INIT_CAP ? RESULT_INIT_CAP : idx->result_cap * GROW_FACTOR; |
| 462 | const cbm_lsh_entry_t **new_buf = |
| 463 | cbm_realloc(CBM_MEM_CLASS_SEMANTIC, idx->result_buf, |
| 464 | (size_t)new_cap * sizeof(const cbm_lsh_entry_t *)); |
| 465 | if (!new_buf) { |
| 466 | return false; |
| 467 | } |
| 468 | idx->result_buf = new_buf; |
| 469 | idx->result_cap = new_cap; |
| 470 | } |
| 471 | idx->result_buf[idx->result_count++] = candidate; |
| 472 | return true; |
| 473 | } |
| 474 | |
| 475 | void cbm_lsh_query(const cbm_lsh_index_t *idx, const cbm_minhash_t *fp, |
| 476 | const cbm_lsh_entry_t ***out, int *count) { |
no test coverage detected