diff options
author | Robin Watts <robin.watts@artifex.com> | 2016-09-16 14:18:09 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2016-09-16 17:26:28 +0100 |
commit | 117b8a8aa53ce1dcf813462b73c1d7d973494bc8 (patch) | |
tree | 45a9c979bc736f2f51641220a7796d6ad619b3f4 /source/pdf/pdf-store.c | |
parent | 7b9eb0d5608c2a76ae7af2b58809e2efeef25afa (diff) | |
download | mupdf-117b8a8aa53ce1dcf813462b73c1d7d973494bc8.tar.xz |
Tweak store handling of PDF document destroy.
When we destroy a PDF document, currently we bin everything
from the store. Instead, drop just the objects that are
specifically tied to that document.
Any object tied to the document has a pdf_obj with the
required document pointer in it as the key.
Diffstat (limited to 'source/pdf/pdf-store.c')
-rw-r--r-- | source/pdf/pdf-store.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/source/pdf/pdf-store.c b/source/pdf/pdf-store.c index fa5cf76e..ccedbe0b 100644 --- a/source/pdf/pdf-store.c +++ b/source/pdf/pdf-store.c @@ -54,6 +54,8 @@ void pdf_store_item(fz_context *ctx, pdf_obj *key, void *val, size_t itemsize) { void *existing; + + assert(pdf_is_array(ctx, key) || pdf_is_dict(ctx, key) || pdf_is_indirect(ctx, key)); existing = fz_store_item(ctx, key, val, itemsize, &pdf_obj_store_type); assert(existing == NULL); (void)existing; /* Silence warning in release builds */ @@ -70,3 +72,19 @@ pdf_remove_item(fz_context *ctx, fz_store_drop_fn *drop, pdf_obj *key) { fz_remove_item(ctx, drop, key, &pdf_obj_store_type); } + +static int +pdf_filter_store(fz_context *ctx, void *doc_, void *key) +{ + pdf_document *doc = (pdf_document *)doc_; + pdf_obj *obj = (pdf_obj *)key; + pdf_document *key_doc = pdf_get_bound_document(ctx, obj); + + return (doc == key_doc); +} + +void +pdf_empty_store(fz_context *ctx, pdf_document *doc) +{ + fz_filter_store(ctx, pdf_filter_store, doc, &pdf_obj_store_type); +} |