diff options
-rw-r--r-- | source/fitz/document.c | 14 | ||||
-rw-r--r-- | source/pdf/pdf-annot.c | 3 |
2 files changed, 8 insertions, 9 deletions
diff --git a/source/fitz/document.c b/source/fitz/document.c index 319ac83b..4cc5dbba 100644 --- a/source/fitz/document.c +++ b/source/fitz/document.c @@ -364,9 +364,9 @@ fz_run_page(fz_context *ctx, fz_page *page, fz_device *dev, const fz_matrix *tra void * fz_new_annot(fz_context *ctx, int size) { - fz_page *page = Memento_label(fz_calloc(ctx, 1, size), "fz_annot"); - page->refs = 1; - return page; + fz_annot *annot = Memento_label(fz_calloc(ctx, 1, size), "fz_annot"); + annot->refs = 1; + return annot; } fz_annot * @@ -380,13 +380,11 @@ fz_keep_annot(fz_context *ctx, fz_annot *annot) void fz_drop_annot(fz_context *ctx, fz_annot *annot) { - if (annot) + if (annot && --annot->refs == 0) { - if (--annot->refs == 0 && annot->drop_annot_imp) - { + if (annot->drop_annot_imp) annot->drop_annot_imp(ctx, annot); - fz_free(ctx, annot); - } + fz_free(ctx, annot); } } diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c index 84b0c3e1..f8e6a770 100644 --- a/source/pdf/pdf-annot.c +++ b/source/pdf/pdf-annot.c @@ -383,7 +383,7 @@ pdf_load_link_annots(fz_context *ctx, pdf_document *doc, pdf_obj *annots, const return head; } -void +static void pdf_drop_annot_imp(fz_context *ctx, pdf_annot *annot) { if (annot->ap) @@ -508,6 +508,7 @@ pdf_load_annots(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_obj *ann obj = pdf_array_get(ctx, annots, i); annot = fz_new_annot(ctx, sizeof(pdf_annot)); + annot->super.drop_annot_imp = (fz_annot_drop_imp_fn*)pdf_drop_annot_imp; annot->super.bound_annot = (fz_annot_bound_fn*)pdf_bound_annot; annot->super.run_annot = (fz_annot_run_fn*)pdf_run_annot; annot->super.next_annot = (fz_annot_next_fn*)pdf_next_annot; |