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

Function objstm_find

internal/cbm/pdf/pdf_obj.c:1404–1421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1402}
1403
1404static int64_t objstm_find(pdf_doc_t *d, pdf_objstm_t *sm, int64_t num, int64_t idx) {
1405 if (idx >= 0 && idx < sm->n && sm->onum[idx] == num) {
1406 return sm->ooff[idx];
1407 }
1408 if (!sm->sorted) {
1409 sm->sorted = (pdf_numidx_t *)pdf_big(d, (size_t)(sm->n ? sm->n : 1) * sizeof(pdf_numidx_t));
1410 if (!sm->sorted) {
1411 return INT64_MIN;
1412 }
1413 for (int i = 0; i < sm->n; i++) {
1414 sm->sorted[i].num = sm->onum[i];
1415 sm->sorted[i].idx = i;
1416 }
1417 qsort(sm->sorted, (size_t)sm->n, sizeof(pdf_numidx_t), numidx_cmp);
1418 }
1419 int k = numidx_first(sm->sorted, sm->n, num);
1420 return k < sm->n ? sm->ooff[sm->sorted[k].idx] : INT64_MIN;
1421}
1422
1423pdf_val_t *pdf_get(pdf_doc_t *d, int64_t num) {
1424 int64_t idx = pdf_map_get(&d->xref.by_num, (uint64_t)num);

Callers 1

pdf_getFunction · 0.85

Calls 2

pdf_bigFunction · 0.85
numidx_firstFunction · 0.85

Tested by

no test coverage detected