Skip to content

Commit

Permalink
Allow to customize FZ_STORE_DEFAULT during compilation and runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
max-kammerer committed Dec 14, 2024
1 parent af5df0b commit 93d0a34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions include/mupdf/fitz/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

/**
Expand Down
5 changes: 4 additions & 1 deletion platform/java/jni/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 93d0a34

Please sign in to comment.