MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_minhash_from_hex

Function cbm_minhash_from_hex

src/simhash/minhash.c:298–315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 3

decode_minhashFunction · 0.85
parse_fp_from_propsFunction · 0.85
test_simhash.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected