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

Function hdr_first_exact

internal/cbm/pdf/pdf_obj.c:1335–1358  ·  view source on GitHub ↗

The first header written exactly "num gen obj" (the prototype's search). */

Source from the content-addressed store, hash-verified

1333
1334/* The first header written exactly "num gen obj" (the prototype's search). */
1335static int64_t hdr_first_exact(pdf_doc_t *d, int64_t num, int64_t gen) {
1336 if (!build_hdrs(d) || !d->nhdrs) {
1337 return -1;
1338 }
1339 if (!d->hdr_sorted) {
1340 d->hdr_sorted = (pdf_numidx_t *)pdf_big(d, (size_t)d->nhdrs * sizeof(pdf_numidx_t));
1341 if (!d->hdr_sorted) {
1342 return -1;
1343 }
1344 for (int i = 0; i < d->nhdrs; i++) {
1345 d->hdr_sorted[i].num = d->hdrs[i].num;
1346 d->hdr_sorted[i].idx = i;
1347 }
1348 qsort(d->hdr_sorted, (size_t)d->nhdrs, sizeof(pdf_numidx_t), numidx_cmp);
1349 }
1350 for (int k = numidx_first(d->hdr_sorted, d->nhdrs, num);
1351 k < d->nhdrs && d->hdr_sorted[k].num == num; k++) {
1352 const pdf_hdr_t *h = &d->hdrs[d->hdr_sorted[k].idx];
1353 if (h->gen == gen && h->canonical) {
1354 return (int64_t)h->off;
1355 }
1356 }
1357 return -1;
1358}
1359
1360static pdf_objstm_t *objstm(pdf_doc_t *d, int64_t stmnum);
1361

Callers 2

length_objectFunction · 0.85
pdf_getFunction · 0.85

Calls 3

build_hdrsFunction · 0.85
pdf_bigFunction · 0.85
numidx_firstFunction · 0.85

Tested by

no test coverage detected