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