aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF_linearization.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2012-06-20 17:20:57 +0200
committerJay Berkenbilt <ejb@ql.org>2012-06-20 21:20:26 +0200
commit5d4cad9c02e9d4f31477fed0e3b20b35c83936f8 (patch)
tree38768f5e4a797e09de304b1e184021f5b280da29 /libqpdf/QPDF_linearization.cc
parent24e2b2b76f1f0051f240c8371b2352c4cde85bf9 (diff)
downloadqpdf-5d4cad9c02e9d4f31477fed0e3b20b35c83936f8.tar.zst
ABI change: fix use of off_t, size_t, and integer types
Significantly improve the code's use of off_t for file offsets, size_t for memory sizes, and integer types in cases where there has to be compatibility with external interfaces. Rework sections of the code that would have prevented qpdf from working on files larger than 2 (or maybe 4) GB in size.
Diffstat (limited to 'libqpdf/QPDF_linearization.cc')
-rw-r--r--libqpdf/QPDF_linearization.cc37
1 files changed, 20 insertions, 17 deletions
diff --git a/libqpdf/QPDF_linearization.cc b/libqpdf/QPDF_linearization.cc
index 9891890f..d4e98dde 100644
--- a/libqpdf/QPDF_linearization.cc
+++ b/libqpdf/QPDF_linearization.cc
@@ -289,7 +289,7 @@ QPDF::readLinearizationData()
PointerHolder<Buffer> hbp = pb.getBuffer();
Buffer* hb = hbp.getPointer();
unsigned char const* h_buf = hb->getBuffer();
- int h_size = hb->getSize();
+ int h_size = (int)hb->getSize();
readHPageOffset(BitStream(h_buf, h_size));
@@ -345,7 +345,7 @@ QPDF::readHintStream(Pipeline& pl, off_t offset, size_t length)
{
QTC::TC("qpdf", "QPDF hint table length direct");
}
- off_t computed_end = offset + length;
+ off_t computed_end = offset + (off_t)length;
if ((computed_end < min_end_offset) ||
(computed_end > max_end_offset))
{
@@ -488,7 +488,7 @@ QPDF::checkLinearizationInternal()
}
// N: number of pages
- int npages = pages.size();
+ int npages = (int)pages.size();
if (p.npages != npages)
{
// Not tested in the test suite
@@ -736,7 +736,7 @@ QPDF::checkHPageOffset(std::list<std::string>& errors,
// under a page's /Resources dictionary in with shared objects
// even when they are private.
- unsigned int npages = pages.size();
+ unsigned int npages = (unsigned int)pages.size();
int table_offset = adjusted_offset(
this->page_offset_hints.first_page_offset);
ObjGen first_page_og(pages[0].getObjectID(), pages[0].getGeneration());
@@ -1425,7 +1425,7 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data)
pages.push_back(getUncompressedObject(*iter, object_stream_data));
}
}
- unsigned int npages = pages.size();
+ unsigned int npages = (unsigned int)pages.size();
// We will be initializing some values of the computed hint
// tables. Specifically, we can initialize any items that deal
@@ -1495,7 +1495,7 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data)
// in garbage values for all the shared object identifiers on the
// first page.
- this->c_page_offset_data.entries[0].nobjects = this->part6.size();
+ this->c_page_offset_data.entries[0].nobjects = (int)this->part6.size();
// Part 7: other pages' private objects
@@ -1646,9 +1646,11 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data)
// Make sure we got everything exactly once.
- unsigned int num_placed = this->part4.size() + this->part6.size() +
- this->part7.size() + this->part8.size() + this->part9.size();
- unsigned int num_wanted = this->object_to_obj_users.size();
+ unsigned int num_placed =
+ (unsigned int)(this->part4.size() + this->part6.size() +
+ this->part7.size() + this->part8.size() +
+ this->part9.size());
+ unsigned int num_wanted = (unsigned int)this->object_to_obj_users.size();
if (num_placed != num_wanted)
{
throw std::logic_error(
@@ -1672,10 +1674,11 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data)
// can map from object number only without regards to generation.
std::map<int, int> obj_to_index;
- this->c_shared_object_data.nshared_first_page = this->part6.size();
+ this->c_shared_object_data.nshared_first_page =
+ (unsigned int)this->part6.size();
this->c_shared_object_data.nshared_total =
this->c_shared_object_data.nshared_first_page +
- this->part8.size();
+ (unsigned int) this->part8.size();
std::vector<CHSharedObjectEntry>& shared =
this->c_shared_object_data.entries;
@@ -1684,7 +1687,7 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data)
{
QPDFObjectHandle& oh = *iter;
int obj = oh.getObjectID();
- obj_to_index[obj] = shared.size();
+ obj_to_index[obj] = (int)shared.size();
shared.push_back(CHSharedObjectEntry(obj));
}
QTC::TC("qpdf", "QPDF lin part 8 empty", this->part8.empty() ? 1 : 0);
@@ -1698,7 +1701,7 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data)
{
QPDFObjectHandle& oh = *iter;
int obj = oh.getObjectID();
- obj_to_index[obj] = shared.size();
+ obj_to_index[obj] = (int)shared.size();
shared.push_back(CHSharedObjectEntry(obj));
}
}
@@ -1814,7 +1817,7 @@ QPDF::calculateHPageOffset(
// values.
std::vector<QPDFObjectHandle> const& pages = getAllPages();
- unsigned int npages = pages.size();
+ unsigned int npages = (unsigned int)pages.size();
CHPageOffset& cph = this->c_page_offset_data;
std::vector<CHPageOffsetEntry>& cphe = cph.entries;
@@ -2019,7 +2022,7 @@ QPDF::writeHPageOffset(BitWriter& w)
w.writeBits(t.nbits_shared_numerator, 16); // 12
w.writeBits(t.shared_denominator, 16); // 13
- unsigned int nitems = getAllPages().size();
+ unsigned int nitems = (unsigned int)getAllPages().size();
std::vector<HPageOffsetEntry>& entries = t.entries;
write_vector_int(w, nitems, entries,
@@ -2110,12 +2113,12 @@ QPDF::generateHintStream(std::map<int, QPDFXRefEntry> const& xref,
BitWriter w(&c);
writeHPageOffset(w);
- S = c.getCount();
+ S = (int)c.getCount();
writeHSharedObject(w);
O = 0;
if (this->outline_hints.nobjects > 0)
{
- O = c.getCount();
+ O = (int)c.getCount();
writeHGeneric(w, this->outline_hints);
}
c.finish();