summaryrefslogtreecommitdiff
path: root/include/mupdf/fitz/context.h
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2017-06-29 12:24:00 +0100
committerRobin Watts <robin.watts@artifex.com>2017-07-04 11:01:00 +0100
commitb9076389f1ede0479d7e48676c60f4c0cc0d6c9a (patch)
tree6d32e662dcfc681d2bd9b091b99ee317d417e96f /include/mupdf/fitz/context.h
parentc87bc4ed995b8dcf50277169fbd00cf6e0a640c8 (diff)
downloadmupdf-b9076389f1ede0479d7e48676c60f4c0cc0d6c9a.tar.xz
Remove is_static from fz_new{,_icc}_colorspace.
No longer required, and causes leaks. Also, fix some reference counting problems with colorspaces.
Diffstat (limited to 'include/mupdf/fitz/context.h')
-rw-r--r--include/mupdf/fitz/context.h36
1 files changed, 24 insertions, 12 deletions
diff --git a/include/mupdf/fitz/context.h b/include/mupdf/fitz/context.h
index 78e64bbc..36d908e8 100644
--- a/include/mupdf/fitz/context.h
+++ b/include/mupdf/fitz/context.h
@@ -612,11 +612,13 @@ fz_keep_imp(fz_context *ctx, void *p, int *refs)
{
if (p)
{
- if (*refs > 0)
- (void)Memento_takeRef(p);
+ (void)Memento_checkIntPointerOrNull(refs);
fz_lock(ctx, FZ_LOCK_ALLOC);
if (*refs > 0)
+ {
+ (void)Memento_takeRef(p);
++*refs;
+ }
fz_unlock(ctx, FZ_LOCK_ALLOC);
}
return p;
@@ -627,11 +629,13 @@ fz_keep_imp8(fz_context *ctx, void *p, int8_t *refs)
{
if (p)
{
- if (*refs > 0)
- (void)Memento_takeRef(p);
+ (void)Memento_checkBytePointerOrNull(refs);
fz_lock(ctx, FZ_LOCK_ALLOC);
if (*refs > 0)
+ {
+ (void)Memento_takeRef(p);
++*refs;
+ }
fz_unlock(ctx, FZ_LOCK_ALLOC);
}
return p;
@@ -642,11 +646,13 @@ fz_keep_imp16(fz_context *ctx, void *p, int16_t *refs)
{
if (p)
{
- if (*refs > 0)
- (void)Memento_takeRef(p);
+ (void)Memento_checkShortPointerOrNull(refs);
fz_lock(ctx, FZ_LOCK_ALLOC);
if (*refs > 0)
+ {
+ (void)Memento_takeRef(p);
++*refs;
+ }
fz_unlock(ctx, FZ_LOCK_ALLOC);
}
return p;
@@ -658,11 +664,13 @@ fz_drop_imp(fz_context *ctx, void *p, int *refs)
if (p)
{
int drop;
- if (*refs > 0)
- (void)Memento_dropRef(p);
+ (void)Memento_checkIntPointerOrNull(refs);
fz_lock(ctx, FZ_LOCK_ALLOC);
if (*refs > 0)
+ {
+ (void)Memento_dropIntRef(p);
drop = --*refs == 0;
+ }
else
drop = 0;
fz_unlock(ctx, FZ_LOCK_ALLOC);
@@ -677,11 +685,13 @@ fz_drop_imp8(fz_context *ctx, void *p, int8_t *refs)
if (p)
{
int drop;
- if (*refs > 0)
- (void)Memento_dropRef(p);
+ (void)Memento_checkBytePointerOrNull(refs);
fz_lock(ctx, FZ_LOCK_ALLOC);
if (*refs > 0)
+ {
+ (void)Memento_dropByteRef(p);
drop = --*refs == 0;
+ }
else
drop = 0;
fz_unlock(ctx, FZ_LOCK_ALLOC);
@@ -696,11 +706,13 @@ fz_drop_imp16(fz_context *ctx, void *p, int16_t *refs)
if (p)
{
int drop;
- if (*refs > 0)
- (void)Memento_dropRef(p);
+ (void)Memento_checkShortPointerOrNull(refs);
fz_lock(ctx, FZ_LOCK_ALLOC);
if (*refs > 0)
+ {
+ (void)Memento_dropShortRef(p);
drop = --*refs == 0;
+ }
else
drop = 0;
fz_unlock(ctx, FZ_LOCK_ALLOC);