From b3d71e1f58aa767dfa8eac3e723ecc164131f306 Mon Sep 17 00:00:00 2001 From: m-holger Date: Mon, 26 Sep 2022 18:27:25 +0100 Subject: [PATCH] Add private overload of QPDF::makeIndirectObject taking a QPDFObject shared_ptr --- include/qpdf/QPDF.hh | 1 + libqpdf/QPDF.cc | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh index 3bda477f..54630a62 100644 --- a/include/qpdf/QPDF.hh +++ b/include/qpdf/QPDF.hh @@ -1187,6 +1187,7 @@ class QPDF QPDFObjectHandle reserveStream(QPDFObjGen const& og); QPDFObjectHandle newIndirect(QPDFObjGen const&, std::shared_ptr const&); + QPDFObjectHandle makeIndirectObject(std::shared_ptr const& obj); bool isCached(QPDFObjGen const& og); bool isUnresolved(QPDFObjGen const& og); void updateCache( diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index 5cad3caf..a870d783 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -1977,7 +1977,7 @@ QPDF::isUnresolved(QPDFObjGen const& og) } QPDFObjectHandle -QPDF::makeIndirectObject(QPDFObjectHandle oh) +QPDF::makeIndirectObject(std::shared_ptr const& obj) { int max_objid = toI(getObjectCount()); if (max_objid == std::numeric_limits::max()) { @@ -1985,11 +1985,16 @@ QPDF::makeIndirectObject(QPDFObjectHandle oh) "max object id is too high to create new objects"); } QPDFObjGen next(max_objid + 1, 0); - m->obj_cache[next] = - ObjCache(QPDFObjectHandle::ObjAccessor::getObject(oh), -1, -1); + m->obj_cache[next] = ObjCache(obj, -1, -1); return newIndirect(next, m->obj_cache[next].object); } +QPDFObjectHandle +QPDF::makeIndirectObject(QPDFObjectHandle oh) +{ + return makeIndirectObject(QPDFObjectHandle::ObjAccessor::getObject(oh)); +} + QPDFObjectHandle QPDF::reserveObjectIfNotExists(QPDFObjGen const& og) {