From 8a5ca0e40690496b3dc820c2f34da032f576a18b Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 6 Jan 2019 22:00:37 -0500 Subject: Don't keep QPDF objects for merging longer than needed --- qpdf/qpdf.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc index b9f5b57b..0250b729 100644 --- a/qpdf/qpdf.cc +++ b/qpdf/qpdf.cc @@ -3671,8 +3671,7 @@ static void handle_transformations(QPDF& pdf, Options& o) } } -static void handle_page_specs(QPDF& pdf, Options& o, - std::vector >& page_heap) +static void handle_page_specs(QPDF& pdf, Options& o) { // Parse all page specifications and translate them into lists of // actual pages. @@ -3715,6 +3714,7 @@ static void handle_page_specs(QPDF& pdf, Options& o, } // Create a QPDF object for each file that we may take pages from. + std::vector > page_heap; std::map page_spec_qpdfs; std::map page_spec_cfis; page_spec_qpdfs[o.infilename] = &pdf; @@ -3727,7 +3727,7 @@ static void handle_page_specs(QPDF& pdf, Options& o, { // Open the PDF file and store the QPDF object. Throw a // PointerHolder to the qpdf into a heap so that it - // survives through writing the output but gets cleaned up + // survives through copying to the output but gets cleaned up // automatically at the end. Do not canonicalize the file // name. Using two different paths to refer to the same // file is a document workaround for duplicating a page. @@ -4273,10 +4273,9 @@ int main(int argc, char* argv[]) } handle_transformations(pdf, o); - std::vector > page_heap; if (! o.page_specs.empty()) { - handle_page_specs(pdf, o, page_heap); + handle_page_specs(pdf, o); } if (! o.rotations.empty()) { -- cgit v1.2.3-70-g09d2