2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 10:58:58 +00:00

In QPDFWriter change object_stream_to_objects to a map of vectors.

This commit is contained in:
m-holger 2024-02-23 14:29:04 +00:00
parent 2fa93e79b4
commit 47cf4e3a50
2 changed files with 9 additions and 7 deletions

View File

@ -2179,12 +2179,14 @@ QPDFWriter::doWriteSetup()
// Generate reverse mapping from object stream to objects
m->obj.forEach([this](auto id, auto const& item) -> void {
if (item.object_stream > 0) {
m->object_stream_to_objects[item.object_stream].insert(QPDFObjGen(id, item.gen));
m->max_ostream_index = std::max(
m->max_ostream_index,
QIntC::to_int(m->object_stream_to_objects[item.object_stream].size()) - 1);
auto& vec = m->object_stream_to_objects[item.object_stream];
vec.emplace_back(id, item.gen);
if (m->max_ostream_index < vec.size()) {
++m->max_ostream_index;
}
}
});
--m->max_ostream_index;
if (m->object_stream_to_objects.empty()) {
m->obj.streams_empty = true;
@ -2431,7 +2433,7 @@ QPDFWriter::writeXRefStream(
unsigned int f1_size = std::max(bytesNeeded(max_offset + hint_length), bytesNeeded(max_id));
// field 2 contains object stream indices
unsigned int f2_size = bytesNeeded(m->max_ostream_index);
unsigned int f2_size = bytesNeeded(QIntC::to_longlong(m->max_ostream_index));
unsigned int esize = 1 + f1_size + f2_size;

View File

@ -97,11 +97,11 @@ class QPDFWriter::Members
int cur_stream_length_id{0};
size_t cur_stream_length{0};
bool added_newline{false};
int max_ostream_index{0};
size_t max_ostream_index{0};
std::set<QPDFObjGen> normalized_streams;
std::map<QPDFObjGen, int> page_object_to_seq;
std::map<QPDFObjGen, int> contents_to_page_seq;
std::map<int, std::set<QPDFObjGen>> object_stream_to_objects;
std::map<int, std::vector<QPDFObjGen>> object_stream_to_objects;
std::list<Pipeline*> pipeline_stack;
unsigned long long next_stack_id{0};
bool deterministic_id{false};