The first header written exactly "num gen obj" (the prototype's search). */
| 1333 | |
| 1334 | /* The first header written exactly "num gen obj" (the prototype's search). */ |
| 1335 | static 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 | |
| 1360 | static pdf_objstm_t *objstm(pdf_doc_t *d, int64_t stmnum); |
| 1361 |
no test coverage detected