diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2018-01-11 14:19:55 +0100 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2018-01-11 14:36:44 +0100 |
commit | 3df11d8c8cc3e6d638d0864d994219ac89f734ad (patch) | |
tree | 9fbdb443c933d88c048c9121e806ce04437a799f /source | |
parent | a2a4ad9dceef9610ddc98b2eadb46c3f377516d1 (diff) | |
download | mupdf-3df11d8c8cc3e6d638d0864d994219ac89f734ad.tar.xz |
Only do lock checking if using custom locks.
The lock checking functions are always enabled in debug mode, but
since they are not thread safe they may not be used in a
multi-threaded application. Multi-threaded applications are
required to set their own locking functions so the lock checking
functions should only be run if the default locking functions
are in use.
Diffstat (limited to 'source')
-rw-r--r-- | source/fitz/memory.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/source/fitz/memory.c b/source/fitz/memory.c index 4b0d5ee3..dc085bec 100644 --- a/source/fitz/memory.c +++ b/source/fitz/memory.c @@ -354,7 +354,12 @@ static int find_context(fz_context *ctx) void fz_assert_lock_held(fz_context *ctx, int lock) { - int idx = find_context(ctx); + int idx; + + if (ctx->locks.lock != fz_lock_default) + return; + + idx = find_context(ctx); if (idx < 0) return; @@ -365,7 +370,12 @@ fz_assert_lock_held(fz_context *ctx, int lock) void fz_assert_lock_not_held(fz_context *ctx, int lock) { - int idx = find_context(ctx); + int idx; + + if (ctx->locks.lock != fz_lock_default) + return; + + idx = find_context(ctx); if (idx < 0) return; @@ -375,8 +385,12 @@ fz_assert_lock_not_held(fz_context *ctx, int lock) void fz_lock_debug_lock(fz_context *ctx, int lock) { - int i; - int idx = find_context(ctx); + int i, idx; + + if (ctx->locks.lock != fz_lock_default) + return; + + idx = find_context(ctx); if (idx < 0) return; @@ -399,7 +413,12 @@ void fz_lock_debug_lock(fz_context *ctx, int lock) void fz_lock_debug_unlock(fz_context *ctx, int lock) { - int idx = find_context(ctx); + int idx; + + if (ctx->locks.lock != fz_lock_default) + return; + + idx = find_context(ctx); if (idx < 0) return; |