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

Function xref_slot

internal/cbm/pdf/pdf_obj.c:1563–1589  ·  view source on GitHub ↗

The entry for num; created (zeroed) when absent. *fresh says which. */

Source from the content-addressed store, hash-verified

1561
1562/* The entry for num; created (zeroed) when absent. *fresh says which. */
1563static pdf_xent_t *xref_slot(pdf_doc_t *d, pdf_xref_t *x, int64_t num, bool *fresh) {
1564 int64_t i = pdf_map_get(&x->by_num, (uint64_t)num);
1565 if (i >= 0) {
1566 *fresh = false;
1567 return &x->v[i];
1568 }
1569 if (x->n == x->cap) {
1570 int ncap = x->cap ? x->cap * 2 : PDF_MAP_MIN;
1571 pdf_xent_t *g =
1572 (pdf_xent_t *)cbm_realloc(CBM_MEM_CLASS_EXTRACT, x->v, (size_t)ncap * sizeof(*g));
1573 if (!g) {
1574 d->nomem = true;
1575 return NULL;
1576 }
1577 x->v = g;
1578 x->cap = ncap;
1579 }
1580 if (!pdf_map_put(&x->by_num, (uint64_t)num, x->n)) {
1581 d->nomem = true;
1582 return NULL;
1583 }
1584 pdf_xent_t *e = &x->v[x->n++];
1585 memset(e, 0, sizeof(*e));
1586 e->num = num;
1587 *fresh = true;
1588 return e;
1589}
1590
1591/* "[ws]*(\d{1,10})[ws]+(\d{1,5})[ws]*([nf])" at p. */
1592static bool match_xref_entry(const pdf_doc_t *d, size_t p, int64_t *off, int64_t *gen, char *kind,

Callers 4

xref_tableFunction · 0.85
xref_rowsFunction · 0.85
load_xrefFunction · 0.85
reconstructFunction · 0.85

Calls 3

pdf_map_getFunction · 0.85
cbm_reallocFunction · 0.85
pdf_map_putFunction · 0.85

Tested by

no test coverage detected