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

Function pdf_scratch

internal/cbm/pdf/pdf_obj.c:101–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101bool pdf_scratch(pdf_doc_t *d, size_t need) {
102 if (need <= d->scratch_cap) {
103 return true;
104 }
105 size_t ncap = d->scratch_cap ? d->scratch_cap : PDF_SCRATCH_MIN;
106 while (ncap < need) {
107 if (ncap > SIZE_MAX / 2) {
108 ncap = need;
109 break;
110 }
111 ncap *= 2;
112 }
113 unsigned char *g = (unsigned char *)cbm_realloc(CBM_MEM_CLASS_EXTRACT, d->scratch, ncap);
114 if (!g) {
115 d->nomem = true;
116 return false;
117 }
118 d->scratch = g;
119 d->scratch_cap = ncap;
120 return true;
121}
122
123/* A growable byte buffer from the memory core (decoder output). */
124typedef struct {

Callers 1

lex_lstrFunction · 0.85

Calls 1

cbm_reallocFunction · 0.85

Tested by

no test coverage detected