summaryrefslogtreecommitdiff
path: root/include/mupdf/fitz/context.h
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-07-08 14:24:54 +0200
committerTor Andersson <tor.andersson@artifex.com>2016-07-08 17:21:24 +0200
commit2be507bfb199e8c80e4b2ee1cb2c867b57fc1f6e (patch)
tree04544d816acc62b02317b9b58c91a7100330d5b0 /include/mupdf/fitz/context.h
parent2791551275e458066b7f1c975d6c8d9e0435051c (diff)
downloadmupdf-2be507bfb199e8c80e4b2ee1cb2c867b57fc1f6e.tar.xz
Use fz_keep_imp and fz_drop_imp for all reference counting.
Diffstat (limited to 'include/mupdf/fitz/context.h')
-rw-r--r--include/mupdf/fitz/context.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/include/mupdf/fitz/context.h b/include/mupdf/fitz/context.h
index b0f3b8cd..ee8ba84e 100644
--- a/include/mupdf/fitz/context.h
+++ b/include/mupdf/fitz/context.h
@@ -607,6 +607,7 @@ fz_keep_imp(fz_context *ctx, void *p, int *refs)
{
if (p)
{
+ Memento_takeRef(p);
fz_lock(ctx, FZ_LOCK_ALLOC);
if (*refs > 0)
++*refs;
@@ -620,6 +621,21 @@ fz_keep_imp8(fz_context *ctx, void *p, int8_t *refs)
{
if (p)
{
+ Memento_takeRef(p);
+ fz_lock(ctx, FZ_LOCK_ALLOC);
+ if (*refs > 0)
+ ++*refs;
+ fz_unlock(ctx, FZ_LOCK_ALLOC);
+ }
+ return p;
+}
+
+static inline void *
+fz_keep_imp16(fz_context *ctx, void *p, int16_t *refs)
+{
+ if (p)
+ {
+ Memento_takeRef(p);
fz_lock(ctx, FZ_LOCK_ALLOC);
if (*refs > 0)
++*refs;
@@ -634,6 +650,7 @@ fz_drop_imp(fz_context *ctx, void *p, int *refs)
if (p)
{
int drop;
+ Memento_dropRef(p);
fz_lock(ctx, FZ_LOCK_ALLOC);
if (*refs > 0)
drop = --*refs == 0;
@@ -651,6 +668,25 @@ fz_drop_imp8(fz_context *ctx, void *p, int8_t *refs)
if (p)
{
int drop;
+ Memento_dropRef(p);
+ fz_lock(ctx, FZ_LOCK_ALLOC);
+ if (*refs > 0)
+ drop = --*refs == 0;
+ else
+ drop = 0;
+ fz_unlock(ctx, FZ_LOCK_ALLOC);
+ return drop;
+ }
+ return 0;
+}
+
+static inline int
+fz_drop_imp16(fz_context *ctx, void *p, int16_t *refs)
+{
+ if (p)
+ {
+ int drop;
+ Memento_dropRef(p);
fz_lock(ctx, FZ_LOCK_ALLOC);
if (*refs > 0)
drop = --*refs == 0;