diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2015-02-17 10:30:59 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2015-02-17 18:06:11 +0100 |
commit | 72679561cddc6b2586e596f62492b79dcf9f118d (patch) | |
tree | 25d156aacc2d2ac3e33170ec42b6501edb9b6754 /source/fitz/image.c | |
parent | 6cc97e85489f5e4e39aa185d17ad5e35b09dddb5 (diff) | |
download | mupdf-72679561cddc6b2586e596f62492b79dcf9f118d.tar.xz |
Add helper functions to keep/drop reference counts with locking.
Add locks around fz_path and fz_text reference counting.
Diffstat (limited to 'source/fitz/image.c')
-rw-r--r-- | source/fitz/image.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/source/fitz/image.c b/source/fitz/image.c index 4c82e2c7..77999ff1 100644 --- a/source/fitz/image.c +++ b/source/fitz/image.c @@ -34,7 +34,6 @@ static int fz_make_hash_image_key(fz_context *ctx, fz_store_hash *hash, void *key_) { fz_image_key *key = (fz_image_key *)key_; - hash->u.pi.ptr = key->image; hash->u.pi.i = key->l2factor; return 1; @@ -44,26 +43,14 @@ static void * fz_keep_image_key(fz_context *ctx, void *key_) { fz_image_key *key = (fz_image_key *)key_; - - fz_lock(ctx, FZ_LOCK_ALLOC); - key->refs++; - fz_unlock(ctx, FZ_LOCK_ALLOC); - - return (void *)key; + return fz_keep_imp(ctx, key, &key->refs); } static void fz_drop_image_key(fz_context *ctx, void *key_) { fz_image_key *key = (fz_image_key *)key_; - int drop; - - if (key == NULL) - return; - fz_lock(ctx, FZ_LOCK_ALLOC); - drop = --key->refs; - fz_unlock(ctx, FZ_LOCK_ALLOC); - if (drop == 0) + if (fz_drop_imp(ctx, key, &key->refs)) { fz_drop_image(ctx, key->image); fz_free(ctx, key); @@ -75,7 +62,6 @@ fz_cmp_image_key(fz_context *ctx, void *k0_, void *k1_) { fz_image_key *k0 = (fz_image_key *)k0_; fz_image_key *k1 = (fz_image_key *)k1_; - return k0->image == k1->image && k0->l2factor == k1->l2factor; } |