| 295 | } |
| 296 | |
| 297 | bool cbm_minhash_from_hex(const char *hex, cbm_minhash_t *out) { |
| 298 | if (!hex || !out) { |
| 299 | return false; |
| 300 | } |
| 301 | size_t len = strlen(hex); |
| 302 | if ((int)len != CBM_MINHASH_HEX_LEN) { |
| 303 | return false; |
| 304 | } |
| 305 | for (int i = 0; i < CBM_MINHASH_K; i++) { |
| 306 | char chunk[HEX_CHARS_PER_U32 + SKIP_ONE]; |
| 307 | ptrdiff_t offset = (ptrdiff_t)i * HEX_CHARS_PER_U32; |
| 308 | memcpy(chunk, hex + offset, HEX_CHARS_PER_U32); |
| 309 | chunk[HEX_CHARS_PER_U32] = '\0'; |
| 310 | unsigned long val = strtoul(chunk, NULL, HEX_BASE); |
| 311 | out->values[i] = (uint32_t)val; |
| 312 | } |
| 313 | return true; |
| 314 | } |
| 315 | |
| 316 | /* ── LSH index ───────────────────────────────────────────────────── */ |
| 317 |
no outgoing calls
no test coverage detected