From 93d0a34e70b62b3b4b2392241d814dfd8587e0fd 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 | 5 +++++ platform/java/jni/context.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/mupdf/fitz/context.h b/include/mupdf/fitz/context.h index 81fad3e5de..098bff9fbb 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, + +#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..b08b7c1fa2 100644 --- a/platform/java/jni/context.c +++ b/platform/java/jni/context.c @@ -146,7 +146,10 @@ 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); + 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");