diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh index 84c1c87..a6fd6d0 100644 --- a/include/qpdf/QPDF.hh +++ b/include/qpdf/QPDF.hh @@ -879,7 +879,7 @@ class QPDF void generateHintStream( QPDFWriter::NewObjTable const& new_obj, QPDFWriter::ObjTable const& obj, - std::shared_ptr& hint_stream, + std::string& hint_stream, int& S, int& O, bool compressed); diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index 54b00b3..9d0b869 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -2341,7 +2341,7 @@ QPDFWriter::writeHeader() void QPDFWriter::writeHintStream(int hint_id) { - std::shared_ptr hint_buffer; + std::string hint_buffer; int S = 0; int O = 0; bool compressed = (m->compress_streams && !m->qdf_mode); @@ -2350,7 +2350,7 @@ QPDFWriter::writeHintStream(int hint_id) openObject(hint_id); setDataKey(hint_id); - size_t hlen = hint_buffer->getSize(); + size_t hlen = hint_buffer.size(); writeString("<< "); if (compressed) { @@ -2370,12 +2370,11 @@ QPDFWriter::writeHintStream(int hint_id) if (m->encrypted) { QTC::TC("qpdf", "QPDFWriter encrypted hint stream"); } - unsigned char last_char = '\0'; + char last_char = hint_buffer.empty() ? '\0' : hint_buffer.back(); { PipelinePopper pp_enc(this); pushEncryptionFilter(pp_enc); - writeBuffer(hint_buffer); - last_char = m->pipeline->getLastChar(); + writeString(hint_buffer); } if (last_char != '\n') { diff --git a/libqpdf/QPDF_linearization.cc b/libqpdf/QPDF_linearization.cc index e4ea689..699977c 100644 --- a/libqpdf/QPDF_linearization.cc +++ b/libqpdf/QPDF_linearization.cc @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -1742,7 +1743,7 @@ void QPDF::generateHintStream( QPDFWriter::NewObjTable const& new_obj, QPDFWriter::ObjTable const& obj, - std::shared_ptr& hint_buffer, + std::string& hint_buffer, int& S, int& O, bool compressed) @@ -1754,7 +1755,7 @@ QPDF::generateHintStream( // Write the hint stream itself into a compressed memory buffer. Write through a counter so we // can get offsets. - Pl_Buffer hint_stream("hint stream"); + Pl_String hint_stream("hint stream", nullptr, hint_buffer); Pipeline* next = &hint_stream; std::shared_ptr flate; if (compressed) { @@ -1774,6 +1775,4 @@ QPDF::generateHintStream( writeHGeneric(w, m->outline_hints); } c.finish(); - - hint_buffer = hint_stream.getBufferSharedPointer(); } diff --git a/libqpdf/qpdf/QPDF_private.hh b/libqpdf/qpdf/QPDF_private.hh index 33621af..54ad4f7 100644 --- a/libqpdf/qpdf/QPDF_private.hh +++ b/libqpdf/qpdf/QPDF_private.hh @@ -39,7 +39,7 @@ class QPDF::Writer QPDF& qpdf, QPDFWriter::NewObjTable const& new_obj, QPDFWriter::ObjTable const& obj, - std::shared_ptr& hint_stream, + std::string& hint_stream, int& S, int& O, bool compressed)