diff options
author | Robin Watts <Robin.Watts@artifex.com> | 2017-03-25 17:39:04 -0400 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2017-03-25 17:40:55 -0400 |
commit | d3087bb261de53557572a49458a2ae88a2d38453 (patch) | |
tree | 4d33583072ab386de7d306c8502bd4f9acdcc999 | |
parent | a78618eae9d21783a17858ad7f0ea5ba21f39e90 (diff) | |
download | mupdf-d3087bb261de53557572a49458a2ae88a2d38453.tar.xz |
Add fz_storable_needs_reaping.
Avoids needing to access the internals of reference counting.
-rw-r--r-- | include/mupdf/fitz/store.h | 5 | ||||
-rw-r--r-- | source/fitz/image.c | 3 |
2 files changed, 6 insertions, 2 deletions
diff --git a/include/mupdf/fitz/store.h b/include/mupdf/fitz/store.h index 65b041f3..a93fca47 100644 --- a/include/mupdf/fitz/store.h +++ b/include/mupdf/fitz/store.h @@ -60,6 +60,11 @@ int fz_drop_key_storable(fz_context *, const fz_key_storable *); void *fz_keep_key_storable_key(fz_context *, const fz_key_storable *); void fz_drop_key_storable_key(fz_context *, const fz_key_storable *); +static inline int fz_key_storable_needs_reaping(fz_context *ctx, const fz_key_storable *ks) +{ + return ks == NULL ? 0 : (ks->store_key_refs == ks->storable.refs); +} + /* The store can be seen as a dictionary that maps keys to fz_storable values. In order to allow keys of different types to be stored, we diff --git a/source/fitz/image.c b/source/fitz/image.c index 9e7717d6..0906d9ad 100644 --- a/source/fitz/image.c +++ b/source/fitz/image.c @@ -92,9 +92,8 @@ static int fz_needs_reap_image_key(fz_context *ctx, void *key_) { fz_image_key *key = (fz_image_key *)key_; - fz_key_storable *ks = &key->image->key_storable; - return (ks->store_key_refs == ks->storable.refs); + return fz_key_storable_needs_reaping(ctx, &key->image->key_storable); } static const fz_store_type fz_image_store_type = |