From 0fc247ff27f881444ac63c2e438cd4c5099c798e Mon Sep 17 00:00:00 2001 From: Michael Bogdanov Date: Sat, 14 Dec 2024 17:30:07 +0100 Subject: [PATCH] Allow to customize FZ_STORE_DEFAULT during compilation and runtime --- include/mupdf/fitz/context.h | 7 ++++++- platform/java/jni/context.c | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/mupdf/fitz/context.h b/include/mupdf/fitz/context.h index 81fad3e5de..4bd38976e8 100644 --- a/include/mupdf/fitz/context.h +++ b/include/mupdf/fitz/context.h @@ -313,7 +313,12 @@ void fz_lock_debug_unlock(fz_context *ctx, int lock); */ enum { FZ_STORE_UNLIMITED = 0, - FZ_STORE_DEFAULT = 256 << 20, + +#ifdef FZ_STORE_DEFAULT_SIZE_IN_MB + FZ_STORE_DEFAULT = FZ_STORE_DEFAULT_SIZE_IN_MB << 20, +#else + FZ_STORE_DEFAULT = 256 << 20, +#endif }; /** diff --git a/platform/java/jni/context.c b/platform/java/jni/context.c index 7d1f7f075b..e1bcac3ea5 100644 --- a/platform/java/jni/context.c +++ b/platform/java/jni/context.c @@ -146,8 +146,11 @@ static int init_base_context(JNIEnv *env) (void)pthread_mutex_init(&mutexes[i], NULL); #endif - base_context = fz_new_context(NULL, &locks, FZ_STORE_DEFAULT); - if (!base_context) + char *env_fz_store_size = getenv("FZ_STORE_SIZE_IN_MB"); + size_t fz_store_size = (env_fz_store_size ? atol(env_fz_store_size) << 20 : FZ_STORE_DEFAULT); + base_context = fz_new_context(NULL, &locks, fz_store_size); + + if (!base_context) { LOGE("cannot create base context"); fin_base_context(env);