diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2016-07-08 14:24:54 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2016-07-08 17:21:24 +0200 |
commit | 2be507bfb199e8c80e4b2ee1cb2c867b57fc1f6e (patch) | |
tree | 04544d816acc62b02317b9b58c91a7100330d5b0 /source/fitz/document.c | |
parent | 2791551275e458066b7f1c975d6c8d9e0435051c (diff) | |
download | mupdf-2be507bfb199e8c80e4b2ee1cb2c867b57fc1f6e.tar.xz |
Use fz_keep_imp and fz_drop_imp for all reference counting.
Diffstat (limited to 'source/fitz/document.c')
-rw-r--r-- | source/fitz/document.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/source/fitz/document.c b/source/fitz/document.c index ad602bc2..b2590f07 100644 --- a/source/fitz/document.c +++ b/source/fitz/document.c @@ -142,16 +142,15 @@ fz_new_document_of_size(fz_context *ctx, int size) fz_document * fz_keep_document(fz_context *ctx, fz_document *doc) { - if (doc) - ++doc->refs; - return doc; + return fz_keep_imp(ctx, doc, &doc->refs); } void fz_drop_document(fz_context *ctx, fz_document *doc) { - if (doc && --doc->refs == 0 && doc->drop_document) - doc->drop_document(ctx, doc); + if (fz_drop_imp(ctx, doc, &doc->refs)) + if (doc->drop_document) + doc->drop_document(ctx, doc); } static void @@ -352,15 +351,13 @@ fz_new_annot(fz_context *ctx, int size) fz_annot * fz_keep_annot(fz_context *ctx, fz_annot *annot) { - if (annot) - ++annot->refs; - return annot; + return fz_keep_imp(ctx, annot, &annot->refs); } void fz_drop_annot(fz_context *ctx, fz_annot *annot) { - if (annot && --annot->refs == 0) + if (fz_drop_imp(ctx, annot, &annot->refs)) { if (annot->drop_annot) annot->drop_annot(ctx, annot); @@ -379,21 +376,17 @@ fz_new_page(fz_context *ctx, int size) fz_page * fz_keep_page(fz_context *ctx, fz_page *page) { - if (page) - ++page->refs; - return page; + return fz_keep_imp(ctx, page, &page->refs); } void fz_drop_page(fz_context *ctx, fz_page *page) { - if (page) + if (fz_drop_imp(ctx, page, &page->refs)) { - if (--page->refs == 0 && page->drop_page) - { + if (page->drop_page) page->drop_page(ctx, page); - fz_free(ctx, page); - } + fz_free(ctx, page); } } |