From ac99be0eb766433e6f0bb6275b3e23791e7b7204 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Sat, 3 Jun 2017 21:25:52 -0700 Subject: Add pdf_keep_document. We have pdf_drop_document, so a pdf_keep_document seems justified too. --- include/mupdf/pdf/document.h | 7 +++++++ source/pdf/pdf-xref.c | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/include/mupdf/pdf/document.h b/include/mupdf/pdf/document.h index 177f947c..68303f05 100644 --- a/include/mupdf/pdf/document.h +++ b/include/mupdf/pdf/document.h @@ -95,6 +95,13 @@ pdf_document *pdf_open_document_with_stream(fz_context *ctx, fz_stream *file); */ void pdf_drop_document(fz_context *ctx, pdf_document *doc); +/* + pdf_keep_document: Keep a reference to an open document. + + Does not throw exceptions. +*/ +pdf_document *pdf_keep_document(fz_context *ctx, pdf_document *doc); + /* pdf_specifics: down-cast a fz_document to a pdf_document. Returns NULL if underlying document is not PDF diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c index ba2689b9..9c98296f 100644 --- a/source/pdf/pdf-xref.c +++ b/source/pdf/pdf-xref.c @@ -1550,6 +1550,12 @@ pdf_drop_document(fz_context *ctx, pdf_document *doc) fz_drop_document(ctx, &doc->super); } +pdf_document * +pdf_keep_document(fz_context *ctx, pdf_document *doc) +{ + return (pdf_document *)fz_keep_document(ctx, &doc->super); +} + /* * compressed object streams */ -- cgit v1.2.3