From 3df11d8c8cc3e6d638d0864d994219ac89f734ad Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Thu, 11 Jan 2018 14:19:55 +0100 Subject: 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. --- source/fitz/memory.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'source/fitz/memory.c') 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; -- cgit v1.2.3