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

Function doc_info_of

internal/cbm/doclink.c:349–374  ·  view source on GitHub ↗

Per-file metadata for this exact immutable doc pointer, never for a line. */

Source from the content-addressed store, hash-verified

347
348/* Per-file metadata for this exact immutable doc pointer, never for a line. */
349static doc_line_ent_t *doc_info_of(CBMExtractCtx *ctx, const char *doc) {
350 doc_line_map_t *m = (doc_line_map_t *)ctx->doc_lines;
351 if (!m || m->count == 0) {
352 return NULL;
353 }
354 if (!m->sorted) {
355 qsort(m->items, (size_t)m->count, sizeof(m->items[0]), doc_line_cmp);
356 m->sorted = true;
357 }
358 int lo = 0;
359 int hi = m->count - SKIP_ONE;
360 uintptr_t key = (uintptr_t)doc;
361 while (lo <= hi) {
362 int mid = lo + ((hi - lo) / PAIR_LEN);
363 uintptr_t v = (uintptr_t)m->items[mid].doc;
364 if (v == key) {
365 return &m->items[mid];
366 }
367 if (v < key) {
368 lo = mid + SKIP_ONE;
369 } else {
370 hi = mid - SKIP_ONE;
371 }
372 }
373 return NULL;
374}
375
376/* ── Persisted scope ─────────────────────────────────────────────── */
377

Callers 2

doclink_file_passFunction · 0.85
cbm_doclinks_extractFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected