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

Function xref_rows

internal/cbm/pdf/pdf_obj.c:1707–1750  ·  view source on GitHub ↗

The rows of a cross-reference stream's decoded bytes into sec. */

Source from the content-addressed store, hash-verified

1705
1706/* The rows of a cross-reference stream's decoded bytes into sec. */
1707static bool xref_rows(pdf_doc_t *d, pdf_xref_t *sec, const unsigned char *raw, size_t rlen,
1708 const int64_t w[3], pdf_val_t **items, int nitems, const int64_t pairs[2]) {
1709 int64_t rec = w[0] + w[1] + w[2];
1710 if (rec == 0) {
1711 return false;
1712 }
1713 size_t pos = 0;
1714 for (int j = 0; j + 1 < nitems; j += 2) {
1715 int64_t start;
1716 int64_t count;
1717 if (items) {
1718 if (!num_to_int(items[j], &start) || !num_to_int(items[j + 1], &count)) {
1719 return false;
1720 }
1721 } else {
1722 start = pairs[0];
1723 count = pairs[1];
1724 }
1725 for (int64_t i = 0; i < count; i++) {
1726 if (pos + (size_t)rec > rlen) {
1727 break;
1728 }
1729 const unsigned char *r = raw + pos;
1730 int64_t t = w[0] ? be_field(r, (int)w[0]) : 1;
1731 int64_t f2 = be_field(r + w[0], (int)w[1]);
1732 int64_t f3 = w[2] ? be_field(r + w[0] + w[1], (int)w[2]) : 0;
1733 pos += (size_t)rec;
1734 bool fresh;
1735 pdf_xent_t *e = xref_slot(d, sec, pdf_sat_add(start, i), &fresh);
1736 if (!e) {
1737 return false;
1738 }
1739 if (!fresh) {
1740 continue;
1741 }
1742 if (t == 1 || t == 2) {
1743 e->type = (uint8_t)t;
1744 e->a = f2;
1745 e->b = f3;
1746 }
1747 }
1748 }
1749 return true;
1750}
1751
1752/* A cross-reference stream at off into sec. Its decoded bytes are freed once
1753 * read: a stream parsed here is no cached object, and keeping them made every

Callers 1

xref_stream_atFunction · 0.85

Calls 4

num_to_intFunction · 0.85
be_fieldFunction · 0.85
xref_slotFunction · 0.85
pdf_sat_addFunction · 0.85

Tested by

no test coverage detected