Commit 8a5ca0e40690496b3dc820c2f34da032f576a18b

Authored by Jay Berkenbilt
1 parent c3cee5f1

Don't keep QPDF objects for merging longer than needed

Showing 1 changed file with 4 additions and 5 deletions
qpdf/qpdf.cc
@@ -3671,8 +3671,7 @@ static void handle_transformations(QPDF& pdf, Options& o) @@ -3671,8 +3671,7 @@ static void handle_transformations(QPDF& pdf, Options& o)
3671 } 3671 }
3672 } 3672 }
3673 3673
3674 -static void handle_page_specs(QPDF& pdf, Options& o,  
3675 - std::vector<PointerHolder<QPDF> >& page_heap) 3674 +static void handle_page_specs(QPDF& pdf, Options& o)
3676 { 3675 {
3677 // Parse all page specifications and translate them into lists of 3676 // Parse all page specifications and translate them into lists of
3678 // actual pages. 3677 // actual pages.
@@ -3715,6 +3714,7 @@ static void handle_page_specs(QPDF&amp; pdf, Options&amp; o, @@ -3715,6 +3714,7 @@ static void handle_page_specs(QPDF&amp; pdf, Options&amp; o,
3715 } 3714 }
3716 3715
3717 // Create a QPDF object for each file that we may take pages from. 3716 // Create a QPDF object for each file that we may take pages from.
  3717 + std::vector<PointerHolder<QPDF> > page_heap;
3718 std::map<std::string, QPDF*> page_spec_qpdfs; 3718 std::map<std::string, QPDF*> page_spec_qpdfs;
3719 std::map<std::string, ClosedFileInputSource*> page_spec_cfis; 3719 std::map<std::string, ClosedFileInputSource*> page_spec_cfis;
3720 page_spec_qpdfs[o.infilename] = &pdf; 3720 page_spec_qpdfs[o.infilename] = &pdf;
@@ -3727,7 +3727,7 @@ static void handle_page_specs(QPDF&amp; pdf, Options&amp; o, @@ -3727,7 +3727,7 @@ static void handle_page_specs(QPDF&amp; pdf, Options&amp; o,
3727 { 3727 {
3728 // Open the PDF file and store the QPDF object. Throw a 3728 // Open the PDF file and store the QPDF object. Throw a
3729 // PointerHolder to the qpdf into a heap so that it 3729 // PointerHolder to the qpdf into a heap so that it
3730 - // survives through writing the output but gets cleaned up 3730 + // survives through copying to the output but gets cleaned up
3731 // automatically at the end. Do not canonicalize the file 3731 // automatically at the end. Do not canonicalize the file
3732 // name. Using two different paths to refer to the same 3732 // name. Using two different paths to refer to the same
3733 // file is a document workaround for duplicating a page. 3733 // file is a document workaround for duplicating a page.
@@ -4273,10 +4273,9 @@ int main(int argc, char* argv[]) @@ -4273,10 +4273,9 @@ int main(int argc, char* argv[])
4273 } 4273 }
4274 4274
4275 handle_transformations(pdf, o); 4275 handle_transformations(pdf, o);
4276 - std::vector<PointerHolder<QPDF> > page_heap;  
4277 if (! o.page_specs.empty()) 4276 if (! o.page_specs.empty())
4278 { 4277 {
4279 - handle_page_specs(pdf, o, page_heap); 4278 + handle_page_specs(pdf, o);
4280 } 4279 }
4281 if (! o.rotations.empty()) 4280 if (! o.rotations.empty())
4282 { 4281 {