mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-01 05:58:12 -06:00
`write_incremental` copied the original into a buffer with 4 KB to spare, then appended the revision. A revision above 4 KB (rotating a few dozen pages, an image, a long comment thread) outgrew it. The buffer was then reallocated at twice the size: the whole original was copied a second time, and the result kept up to the original's size again unused. The engine keeps that result as the document's working bytes, shared with the renderer and handed to Save, so the unused half stayed alive. A 100 MB document held a 200 MB allocation after one such edit, and still did after saving. The revision is now written on its own, with offsets counted from where it will start. The result is allocated once at exactly the original's size plus the revision's, and filled in one pass. The output is byte for byte what it was before. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>