diff options
author | Robin Watts <robin.watts@artifex.com> | 2017-11-08 19:45:14 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2017-11-09 12:41:52 +0000 |
commit | 258f03a0a55c1aa802e1be47e463d8abc5096196 (patch) | |
tree | 7596f3081254276b29d929aa87b233a04d02ce51 /source/fitz/context.c | |
parent | 9f32fdff17f9d6cb114c4f70d1e4b8364e8b5d11 (diff) | |
download | mupdf-258f03a0a55c1aa802e1be47e463d8abc5096196.tar.xz |
Bug 698353: Avoid having our API depend on DEBUG/NDEBUG.
Currently, our API uses static inlines for fz_lock and
fz_unlock, the definitions for which depend on whether
we build NDEBUG or not. This isn't ideal as it causes
problems when people link a release binary with a debug
lib (or vice versa).
We really want to continue to use static inlines for the
locking functions as used from MuPDF, as we hit them
hard in the keep/drop functions.
We therefore remove fz_lock/fz_unlock from the public API
entirely. Accordingly, we move the fz_lock/fz_unlock
static inlines into fitz-imp.h (an internal header),
together with the fz_keep_.../fz_drop_... functions.
We then have public fz_lock/fz_unlock functions for any
external callers to use that are free of compilications.
At the same time, to avoid another indirection, we change
from holding the locking functions as a pointer to a
struct to a struct itself.
Diffstat (limited to 'source/fitz/context.c')
-rw-r--r-- | source/fitz/context.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/source/fitz/context.c b/source/fitz/context.c index b342e6e1..f4ebdc98 100644 --- a/source/fitz/context.c +++ b/source/fitz/context.c @@ -181,7 +181,7 @@ new_context_phase1(const fz_alloc_context *alloc, const fz_locks_context *locks) memset(ctx, 0, sizeof *ctx); ctx->user = NULL; ctx->alloc = alloc; - ctx->locks = locks; + ctx->locks = *locks; ctx->glyph_cache = NULL; @@ -265,7 +265,7 @@ fz_clone_context(fz_context *ctx) { /* We cannot safely clone the context without having locking/ * unlocking functions. */ - if (ctx == NULL || ctx->locks == &fz_locks_default) + if (ctx == NULL || (ctx->locks.lock == fz_locks_default.lock && ctx->locks.unlock == fz_locks_default.unlock)) return NULL; return fz_clone_context_internal(ctx); } @@ -278,7 +278,7 @@ fz_clone_context_internal(fz_context *ctx) if (ctx == NULL || ctx->alloc == NULL) return NULL; - new_ctx = new_context_phase1(ctx->alloc, ctx->locks); + new_ctx = new_context_phase1(ctx->alloc, &ctx->locks); if (!new_ctx) return NULL; |