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

Add private overload of QPDF::makeIndirectObject taking a QPDFObject shared_ptr

This commit is contained in:
m-holger 2022-09-26 18:27:25 +01:00 committed by Jay Berkenbilt
parent 486c273a4f
commit b3d71e1f58
2 changed files with 9 additions and 3 deletions

View File

@ -1187,6 +1187,7 @@ class QPDF
QPDFObjectHandle reserveStream(QPDFObjGen const& og);
QPDFObjectHandle
newIndirect(QPDFObjGen const&, std::shared_ptr<QPDFObject> const&);
QPDFObjectHandle makeIndirectObject(std::shared_ptr<QPDFObject> const& obj);
bool isCached(QPDFObjGen const& og);
bool isUnresolved(QPDFObjGen const& og);
void updateCache(

View File

@ -1977,7 +1977,7 @@ QPDF::isUnresolved(QPDFObjGen const& og)
}
QPDFObjectHandle
QPDF::makeIndirectObject(QPDFObjectHandle oh)
QPDF::makeIndirectObject(std::shared_ptr<QPDFObject> const& obj)
{
int max_objid = toI(getObjectCount());
if (max_objid == std::numeric_limits<int>::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)
{