Commit 953ed4b84e7ee7f304cdebab127e937245f3c48b

Authored by m-holger
1 parent 7cc1e08d

In QPDFWriter::writeHintStream use std::string instead of std::shared_ptr<Buffer>

include/qpdf/QPDF.hh
... ... @@ -879,7 +879,7 @@ class QPDF
879 879 void generateHintStream(
880 880 QPDFWriter::NewObjTable const& new_obj,
881 881 QPDFWriter::ObjTable const& obj,
882   - std::shared_ptr<Buffer>& hint_stream,
  882 + std::string& hint_stream,
883 883 int& S,
884 884 int& O,
885 885 bool compressed);
... ...
libqpdf/QPDFWriter.cc
... ... @@ -2341,7 +2341,7 @@ QPDFWriter::writeHeader()
2341 2341 void
2342 2342 QPDFWriter::writeHintStream(int hint_id)
2343 2343 {
2344   - std::shared_ptr<Buffer> hint_buffer;
  2344 + std::string hint_buffer;
2345 2345 int S = 0;
2346 2346 int O = 0;
2347 2347 bool compressed = (m->compress_streams && !m->qdf_mode);
... ... @@ -2350,7 +2350,7 @@ QPDFWriter::writeHintStream(int hint_id)
2350 2350 openObject(hint_id);
2351 2351 setDataKey(hint_id);
2352 2352  
2353   - size_t hlen = hint_buffer->getSize();
  2353 + size_t hlen = hint_buffer.size();
2354 2354  
2355 2355 writeString("<< ");
2356 2356 if (compressed) {
... ... @@ -2370,12 +2370,11 @@ QPDFWriter::writeHintStream(int hint_id)
2370 2370 if (m->encrypted) {
2371 2371 QTC::TC("qpdf", "QPDFWriter encrypted hint stream");
2372 2372 }
2373   - unsigned char last_char = '\0';
  2373 + char last_char = hint_buffer.empty() ? '\0' : hint_buffer.back();
2374 2374 {
2375 2375 PipelinePopper pp_enc(this);
2376 2376 pushEncryptionFilter(pp_enc);
2377   - writeBuffer(hint_buffer);
2378   - last_char = m->pipeline->getLastChar();
  2377 + writeString(hint_buffer);
2379 2378 }
2380 2379  
2381 2380 if (last_char != '\n') {
... ...
libqpdf/QPDF_linearization.cc
... ... @@ -8,6 +8,7 @@
8 8 #include <qpdf/Pl_Buffer.hh>
9 9 #include <qpdf/Pl_Count.hh>
10 10 #include <qpdf/Pl_Flate.hh>
  11 +#include <qpdf/Pl_String.hh>
11 12 #include <qpdf/QPDFExc.hh>
12 13 #include <qpdf/QPDFLogger.hh>
13 14 #include <qpdf/QPDFWriter_private.hh>
... ... @@ -1742,7 +1743,7 @@ void
1742 1743 QPDF::generateHintStream(
1743 1744 QPDFWriter::NewObjTable const& new_obj,
1744 1745 QPDFWriter::ObjTable const& obj,
1745   - std::shared_ptr<Buffer>& hint_buffer,
  1746 + std::string& hint_buffer,
1746 1747 int& S,
1747 1748 int& O,
1748 1749 bool compressed)
... ... @@ -1754,7 +1755,7 @@ QPDF::generateHintStream(
1754 1755  
1755 1756 // Write the hint stream itself into a compressed memory buffer. Write through a counter so we
1756 1757 // can get offsets.
1757   - Pl_Buffer hint_stream("hint stream");
  1758 + Pl_String hint_stream("hint stream", nullptr, hint_buffer);
1758 1759 Pipeline* next = &hint_stream;
1759 1760 std::shared_ptr<Pipeline> flate;
1760 1761 if (compressed) {
... ... @@ -1774,6 +1775,4 @@ QPDF::generateHintStream(
1774 1775 writeHGeneric(w, m->outline_hints);
1775 1776 }
1776 1777 c.finish();
1777   -
1778   - hint_buffer = hint_stream.getBufferSharedPointer();
1779 1778 }
... ...
libqpdf/qpdf/QPDF_private.hh
... ... @@ -39,7 +39,7 @@ class QPDF::Writer
39 39 QPDF& qpdf,
40 40 QPDFWriter::NewObjTable const& new_obj,
41 41 QPDFWriter::ObjTable const& obj,
42   - std::shared_ptr<Buffer>& hint_stream,
  42 + std::string& hint_stream,
43 43 int& S,
44 44 int& O,
45 45 bool compressed)
... ...